Construct and manage graphical, event-driven user interfaces for iOS or tvOS apps using UIKit.

Posts under UIKit tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Disable the keyboard suggestions for a UITextField
I have a UITableView with a bunch of UITextFields in 'em. (in a custom UITableViewCell subclass) For every UITextField I have set: cell.textField.textContentType = .none I even tried: cell.textField.inlinePredictionType = .no // iOS >= 17 and: cell.textField.keyboardType = .default cell.textField.autocorrectionType = .no cell.textField.spellCheckingType = .no cell.textField.autocapitalizationType = .none Still, when I tap in one of them, I get a 'suggestion' in a bar just above the Keyboard that I can fill in my phone number. How can I prevent that? I am using: xcode 15.4, iOS 17.5.1. Compiling for iOS 13.0 and later.
1
0
91
1h
Expandable UIView inside Navigation Bar can't be clicked/tapped
Hello Team we facing a problem with a UIView inside of a Navigation Bar what we need to achieve is to place a UIView (SwiftUI Wrapper) on the middle of the Navigation bar Here's how it looks like right now that's already complete, but now the problem that we are facing is that the View is not detecting the clicks/taps on the 'dates and 'travelers' here's the Code for the View private lazy var sharedUIPlaybackView: UIView = { let containerView = UIView().withAutoLayout() containerView.backgroundColor = .red containerView.styleBorder(color: .systemPink, width: 1) let propertySearchCriteria = PropertySearchCriteriaBuilder(hotelSearchParameters: viewModel.hotelSearchParameters).criteria var swiftUIView: SwiftUIView<LodgingPlaybackWrapper>! = nil swiftUIView = SwiftUIView( LodgingPlaybackWrapper(propertySearchCriteria: propertySearchCriteria, playbackUpdateNotificationSender: nil, componentHandler: { [weak self] componentId in self?.componentReady(componentId) }), viewDidLayoutSubviewsCallback: { [weak self] in let newHeight = swiftUIView.frame.size.height if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant { self?.sharedUIPlaybackViewHeightConstraint?.constant = newHeight self?.additionalSafeAreaInsets.top = 200 } } ).withAutoLayout().withAccessibilityIdentifier("searchPlayback") sharedUIPlaybackViewHeightConstraint = containerView.heightAnchor.constraint(equalToConstant: 0) sharedUIPlaybackViewHeightConstraint?.isActive = true swiftUIView.backgroundColor = .blue swiftUIView.styleBorder(color: .orange, width: 1) containerView.addSubview(swiftUIView) containerView.addConstraints([ swiftUIView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: Spacing.spacing4x), swiftUIView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -Spacing.spacing4x) ]) self.view.bringSubviewToFront(swiftUIView) swiftUIView.isUserInteractionEnabled = true swiftUIView.layer.zPosition = 1 return containerView }() my first suspicion was that the this part of the code was not expanding correctly viewDidLayoutSubviewsCallback: { [weak self] in let newHeight = swiftUIView.frame.size.height if newHeight != self?.sharedUIPlaybackViewHeightConstraint?.constant { self?.sharedUIPlaybackViewHeightConstraint?.constant = newHeight self?.additionalSafeAreaInsets.top = 200 } } but after I place border and background colors on the views was clear for me that it was expanding properly, so I added some modifiers for the view like swiftUIView.isUserInteractionEnabled = true swiftUIView.layer.zPosition = 1 but didn't work, I'm asking for a solution and different point of view for the code to be more cleaner and do the best implementation posible. This Navigation bar should be treated as a custom Navigation Bar, or it is good for us to expand and treat the Navigation bar like this? (expanding and adding a Custom View) thanks in advance to anyone who read this. here's the View Hierarchy
0
0
125
3d
Swift Playgrounds 4.1 keeps crashing when rerunning code
Try to learn some Swift coding but Playgrounds keeps crashing. I run Playgrounds 4.1 on latest Monterey 12.7.5, from a MacBook Air dated back 2017. Part of the error log says: Thread 9 Crashed:: Dispatch queue: com.apple.UIKit._UIViewServiceInterfaceConnectionRequest com.apple.PlaygroundsMac.ExecutionExtension The error can be reproduced by re-running the code; Everything goes well when the code was run at first time, but is doomed to fail at second run. Any help?
0
0
119
5d
UITableView setTableHeaderView
我遇到了一个问题,当一个View是tableview的tableHeaderview时,我把View重新嵌套一层重新设置给tableHeaderview,这个View不展示 代码如下: UIView *view = [UIView new]; tableView.tableHeaderview = view; UiView *otherView = [UIview new]; otherView addSubview:view]; tableView.tableHeaderview = otherView; 这个时候view不展示了。 根据调用栈看,设置tableHeaderview后,view执行了一次removeFromSuperview,从otherView中消失了。 所以想了解一下,当设置新的tableHeaderview,对旧的HeaderView是怎么处理的?
1
0
100
4d
Spelling/grammar check settings persistence in UITextView on Mac Catalyst
In our Mac Catalyst app running on macOS, the Edit > Spelling and Grammar > Check Spelling While Typing, Check Grammar With Spelling, and Correct Spelling Automatically preferences are reset with each opening of a new text view. How can we make those preferences persistent? Ie, when someone changes those settings for our app's text view, other incarnations of our app's text views should respect the latest preferences. We looked at swizzling NSTextView's toggleAutomaticSpellingCorrection:, saving those to NSUserDefaults, and then reading those preferences when we set up our UITextView subclass, and then setting the UITextInputTraits properties accordingly. However, our approach felt heavy handed, and I'm wondering if we are missing some out-of-the-box functionality that will make those preferences intuitively persistent. Does anyone have any suggestions? Thank you.
0
0
115
1w
ios app crash
This is crash stack. What caused this crash? How to solve it? Date/Time: 2024-05-17 11:12:48.0370 +0800 Launch Time: 2024-05-17 11:12:28.4598 +0800 OS Version: iPhone OS 17.4.1 (21E236) Release Type: User Baseband Version: 3.50.04 Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x00000001aee09920 Triggered by Thread: 0 Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter Thread 0 Crashed: 0 libdispatch.dylib 0x00000001aee09920 _dispatch_lane_resume + 712 (queue.c:3284) 1 CoreFoundation 0x00000001a6f357a8 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148 (CFNotificationCenter.c:700) 2 CoreFoundation 0x00000001a6f35170 ___CFXRegistrationPost_block_invoke + 88 (CFNotificationCenter.c:193) 3 CoreFoundation 0x00000001a6f350b8 _CFXRegistrationPost + 440 (CFNotificationCenter.c:221) 4 CoreFoundation 0x00000001a6f34608 _CFXNotificationPost + 728 (CFNotificationCenter.c:1247) 5 Foundation 0x00000001a5dc6f10 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92 (NSNotification.m:531) 6 UIKitCore 0x00000001a930f04c -[UIApplication _sendWillEnterForegroundCallbacks] + 212 (UIApplication.m:11709) 7 UIKitCore 0x00000001a930d7cc __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 + 1272 (_UISceneLifecycleMultiplexer.m:653) 8 UIKitCore 0x00000001a930d298 _UIScenePerformActionsWithLifecycleActionMask + 112 (_UISceneLifecycleState.m:109) 9 UIKitCore 0x00000001a9393934 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 216 (_UISceneLifecycleMultiplexer.m:566) 10 UIKitCore 0x00000001a92bcac4 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 220 (_UISceneLifecycleMultiplexer.m:515) 11 UIKitCore 0x00000001a92bb53c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 608 (_UISceneLifecycleMultiplexer.m:565) 12 UIKitCore 0x00000001a92baea4 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 248 (_UISceneLifecycleMultiplexer.m:468) 13 UIKitCore 0x00000001a92bad74 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block... + 148 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:73) 14 UIKitCore 0x00000001a92bac7c +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 736 (BSAnimationSettings+UIKit.m:54) 15 UIKitCore 0x00000001a92ba504 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion + 224 (_UISceneSettingsDiffAction.m:27) 16 UIKitCore 0x00000001a92ba1b4 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 316 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:58) 17 UIKitCore 0x00000001a964ae20 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.226 + 612 (UIScene.m:2067) 18 UIKitCore 0x00000001a92b9328 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 216 (UIScene.m:1736) 19 UIKitCore 0x00000001a92b9198 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 244 (UIScene.m:2026) 20 UIKitCore 0x00000001a92b8fd8 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 336 (UIApplicationSceneClientAgent.m:86) 21 FrontBoardServices 0x00000001bfaeb524 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 660 (FBSScene.m:812) 22 FrontBoardServices 0x00000001bfaeb270 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 + 152 (FBSWorkspaceScenesClient.m:692) 23 FrontBoardServices 0x00000001bfaeb10c -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 168 (FBSWorkspace.m:411) 24 FrontBoardServices 0x00000001bfaeb028 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke + 344 (FBSWorkspaceScenesClient.m:691) 25 libdispatch.dylib 0x00000001aee02dd4 _dispatch_client_callout + 20 (object.m:576) 26 libdispatch.dylib 0x00000001aee0686c _dispatch_block_invoke_direct + 288 (queue.c:511) 27 FrontBoardServices 0x00000001bfae7490 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 52 (FBSSerialQueue.m:285) 28 FrontBoardServices 0x00000001bfae7410 -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 240 (FBSSerialQueue.m:309) 29 FrontBoardServices 0x00000001bfae72e8 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:322) 30 CoreFoundation 0x00000001a6f3d62c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957) 31 CoreFoundation 0x00000001a6f3c8a8 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001) 32 CoreFoundation 0x00000001a6f3b058 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2038) 33 CoreFoundation 0x00000001a6f39d88 __CFRunLoopRun + 828 (CFRunLoop.c:2955) 34 CoreFoundation 0x00000001a6f39968 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420) 35 GraphicsServices 0x00000001eb22f4e0 GSEventRunModal + 164 (GSEvent.c:2196) 36 UIKitCore 0x00000001a93acedc -[UIApplication _run] + 888 (UIApplication.m:3692) 37 UIKitCore 0x00000001a93ac518 UIApplicationMain + 340 (UIApplication.m:5282) 38 VRCapture 0x00000001045ac3a4 main + 84 (main.m:33) 39 dyld 0x00000001ca45ad84 start + 2240 (dyldMain.cpp:1298)
0
0
120
1w
App crashes in CGFontStrikeRelease
This crash has been troubling us for a long time. We have this crash report in every release of our App, but can't reproduce it. Here is part of the crash info: Incident Identifier: xxxx Hardware Model: iPhone13,3 Process: MyApp [34550] Path: /private/var/containers/Bundle/Application/xxxx/MyApp.app/MyApp Identifier: ***.*** Version: *** (296) AppStoreTools: 15F31c AppVariant: 1:iPhone13,3:15 Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: ***.*** [466] Date/Time: 2024-05-19 13:59:10.9716 +0800 Launch Time: 2024-05-19 12:18:24.8753 +0800 OS Version: iPhone OS 16.6.1 (20G81) Release Type: User Baseband Version: 3.80.01 Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x322e323400000000 -> 0x0000003400000000 (possible pointer authentication failure) Exception Codes: 0x0000000000000001, 0x322e323400000000 VM Region Info: 0x3400000000 is in 0x1000000000-0x7000000000; bytes after start: 154618822656 bytes before end: 257698037759 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL commpage (reserved) fc0000000-1000000000 [ 1.0G] ---/--- SM=NUL ...(unallocated) ---> GPU Carveout (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated) UNUSED SPACE AT END Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 CoreGraphics 0x00000001bd1d0780 CGFontStrikeRelease + 76 (CGFontStrike.c:126) 1 CoreGraphics 0x00000001bd1dd0cc CGGlyphBuilderUnlockBitmaps + 476 (CGGlyphBuilder.cc:113) 2 CoreGraphics 0x00000001bd1eb8c8 render_glyphs + 412 (RIPContextDrawGlyphs.c:127) 3 CoreGraphics 0x00000001bd202ea4 draw_glyph_bitmaps + 1132 (RIPContextDrawGlyphs.c:210) 4 CoreGraphics 0x00000001bd21a0ec ripc_DrawGlyphs + 1320 (RIPContextDrawGlyphs.c:558) 5 CoreGraphics 0x00000001bd1d26d8 CG::DisplayList::executeEntries(std::__1::__wrap_iter<std::__1::unique_ptr<CG::DisplayListEntry const, std::__1::default_delete<CG::DisplayListEntry const> >*>, std::__1::__wrap_iter<std::__1::uniq... + 5852 (DisplayList.cpp:1657) 6 CoreGraphics 0x00000001bd1c86a8 CGDisplayListDrawInContextDelegate + 268 (DisplayList.cpp:2151) 7 QuartzCore 0x00000001bcc797d4 CABackingStoreUpdate_ + 468 (CABackingStore.cpp:1388) 8 QuartzCore 0x00000001bccf0c34 invocation function for block in CA::Layer::display_() + 64 (CALayer.mm:9699) 9 QuartzCore 0x00000001bcc78d54 -[CALayer _display] + 1720 (CALayer.mm:9732) 10 QuartzCore 0x00000001bcc785b4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 412 (CALayer.mm:2521) 11 QuartzCore 0x00000001bcc898d8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 444 (CAContextInternal.mm:2714) 12 QuartzCore 0x00000001bccb8e80 CA::Transaction::commit() + 648 (CATransactionInternal.mm:432) 13 QuartzCore 0x00000001bcca2df0 CA::Transaction::flush_as_runloop_observer(bool) + 88 (CATransactionInternal.mm:940) 14 UIKitCore 0x00000001bdca34d0 _UIApplicationFlushCATransaction + 52 (UIApplication.m:3286) 15 UIKitCore 0x00000001bddf3d94 _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:114) 16 UIKitCore 0x00000001be458894 schedulerStepScheduledMainSection + 144 (_UIUpdateScheduler.m:1015) 17 UIKitCore 0x00000001be457df0 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1164) 18 CoreFoundation 0x00000001bb80a128 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957) 19 CoreFoundation 0x00000001bb8167b4 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001) 20 CoreFoundation 0x00000001bb79b5e8 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2038) 21 CoreFoundation 0x00000001bb7b10d4 __CFRunLoopRun + 828 (CFRunLoop.c:2953) 22 CoreFoundation 0x00000001bb7b63ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418) 23 GraphicsServices 0x00000001f6ccc35c GSEventRunModal + 164 (GSEvent.c:2196) 24 UIKitCore 0x00000001bdb42f58 -[UIApplication _run] + 888 (UIApplication.m:3782) 25 UIKitCore 0x00000001bdb42bbc UIApplicationMain + 340 (UIApplication.m:5372) 26 MyApp 0x000000010468f978 main + 80 (main.m:15) 27 dyld 0x00000001dace8dec start + 2220 (dyldMain.cpp:1165) Thread 1 name: Thread 1: 0 libsystem_kernel.dylib 0x00000001fa6f6ca4 mach_msg2_trap + 8 (:-1) 1 libsystem_kernel.dylib 0x00000001fa709b74 mach_msg2_internal + 80 (mach_msg.c:201) 2 libsystem_kernel.dylib 0x00000001fa709e4c mach_msg_overwrite + 540 (mach_msg.c:0) 3 libsystem_kernel.dylib 0x00000001fa6f71e8 mach_msg + 24 (mach_msg.c:323) 4 CoreFoundation 0x00000001bb7b0024 __CFRunLoopServiceMachPort + 160 (CFRunLoop.c:2622) 5 CoreFoundation 0x00000001bb7b1250 __CFRunLoopRun + 1208 (CFRunLoop.c:3005) 6 CoreFoundation 0x00000001bb7b63ec CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418) 7 Foundation 0x00000001b5a2efb4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212 (NSRunLoop.m:373) 8 Foundation 0x00000001b5a2ee9c -[NSRunLoop(NSRunLoop) runUntilDate:] + 64 (NSRunLoop.m:420) 9 UIKitCore 0x00000001bdc75cc8 -[UIEventFetcher threadMain] + 416 (UIEventFetcher.m:1376) 10 Foundation 0x00000001b5a48524 __NSThread__start__ + 716 (NSThread.m:963) 11 libsystem_pthread.dylib 0x000000021b5766b8 _pthread_start + 148 (pthread.c:893) 12 libsystem_pthread.dylib 0x000000021b575b88 thread_start + 8 (:-1) Thread 2: 0 libsystem_kernel.dylib 0x00000001fa6f7164 __semwait_signal + 8 (:-1) 1 libsystem_c.dylib 0x00000001c2c50888 nanosleep + 220 (nanosleep.c:104) 2 libsystem_c.dylib 0x00000001c2c61b1c sleep + 52 (sleep.c:62) 3 MyApp 0x00000001075ccb14 -[UTDCacheManager synchronizeData] + 104 (UTDCacheManager.m:133) 4 Foundation 0x00000001b5a48524 __NSThread__start__ + 716 (NSThread.m:963) 5 libsystem_pthread.dylib 0x000000021b5766b8 _pthread_start + 148 (pthread.c:893) 6 libsystem_pthread.dylib 0x000000021b575b88 thread_start + 8 (:-1)
0
0
92
1w
iOS App multiple UIWindows become unresponsive to touch events after device rotation animation
I am developing an App. There are multiple windows in it. A main window that shows the main UI of the app, and some other util windows that are created dynamically when needed. All of these windows have their rootviewcontrollers, and they all support all the userinterface orientations. But when I rotate the device, the windows seemed rotate to the right orientation, but some window has four strange black rectangles along each side. And the worse thing is that the whole app become freezed, it does not respond to touch event, I need to force quit it. I did a lot of experiments to find out the cause of this issue in last two months. I found some truth about this issue: Good Case: If the App only has the main window, the issue gone. If the rotation animation completed, the issue gone. the attachment shows some callstacks when rotation animation completed. goodcase-animation-callstacks Bad Case: When the issue occurs, I find out the rotation animation does not complete. This is some code of rootviewcontroller: - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; NSLog(@"%s, size: %@", __PRETTY_FUNCTION__, NSStringFromCGSize(size)); NSLog(@"%@", NSThread.callStackSymbols); NSLog(@"%@", self.view); NSLog(@"%@", self.view.subviews); [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { NSLog(@"animation block"); fprintf(stderr, "stderr animation block\n"); fprintf(stdout, "stdout animation block\n"); NSLog(@"%@", NSThread.callStackSymbols); NSLog(@"animation block SDL_uikitviewcontroller runloop mode: %@", NSRunLoop.currentRunLoop.currentMode); NSLog(@"%@", self.view); NSLog(@"%@", self.view.subviews); } completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { NSLog(@"completion block, isCancelled: %@", context.isCancelled ? @"YES" : @"NO"); fprintf(stderr, "stderr animation completion block\n"); fprintf(stdout, "stdout animation completion block\n"); NSLog(@"%@", NSThread.callStackSymbols); NSLog(@"animation complete block SDL_uikitviewcontroller runloop mode: %@", NSRunLoop.currentRunLoop.currentMode); }]; [coordinator notifyWhenInteractionChangesUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { NSLog(@"%s", __PRETTY_FUNCTION__); }]; } I guess this issue is similar to another common issue: UINavigationController push/pop viewcontroller when previous push/pop animation is running, or showing a UIAlertController when viewcontroller is being pushing/popping They all have the same result, the app become unresponsive to touch events, but they can respond to other events(I did some test, the app is still running, not in a deadlock state, it just can not respond to touch events) I guess the root cause of this issue is the animations conflict, or the view hierarchy changed when animating, so the animation states and the view hierarchy were messed up. But I don't know how to fix it. I have a workaround, but it has side effect.
1
0
130
1w
UICollectionViewCompositionalLayout section.decorationItems crash in iOS 16
Hi, I am using compositional layout on my UICollectionView. For my sections I have added a decorationItem which is a UICollectionReusableView. Everything seems to work fine on all iOS versions, except iOS 16, where I'm getting an unexpected crash. The Firebase Crashlytics report says as follows: Fatal Exception: NSInternalInconsistencyException Invalid parameter not satisfying: sectionIndex < self.solutionBookmarks.count This happens right after I'm reloading my collectionView after fetching data from API. Any help would be appreciated on this, since I can't seem to debug this issue whatsoever. Thanks
1
0
95
1w
Moving the selection handles in UITextSelectionDisplayInteraction
I am attempting to use UITextSelectionDisplayInteraction. It basically works, but I'm unsure how the selection handles are supposed to work. The documentation is minimal and the WWDC video (2023 session 10058) doesn't say much either. As the name suggests, it seems that this interaction only displays the cursor, selection background, and handles. As I change the selection, it updates these views. So if I want the user to be able to drag the selection handles I need to implement that, right? OK, so I add a gesture recognizer to each selection handle. But this doesn't seem to do anything, i.e. the gesture recognizer action never seems to be invoked. Maybe I'm doing something wrong - but I'd like to understand what is supposed to happen. Is adding a pan gesture recognizer to each selection handle the right approach? P.S. I wanted to tag this "WWDC2023-10058", but the per-session tags seem to have disappeared. Is this a forum bug, or deliberate?
0
0
107
1w
Xcode15 crash reloadItems - Invalid update: invalid number of items in section
Xcode15 crash reloadItems - Invalid update: invalid number of items in section When building with xcode14, there was no crash when calling collectionView reloadItems. If you build with xcode15 A crash pops up saying Invalid update: invalid number of items in section. The current issue has been resolved, but I would like to know the exact cause of the crash in xcode 15. Does anyone know?
3
0
160
1w
iOS app crash with UIKitcore - UIAlertController
I have recently submitted a new app version to the Appstore with Xcode 15.0. Unfortunately, I have started to see the below crash in the Xcode organiser &gt; Crashes section occurring for more number of times. UIKitCore: +[UIAlertController _alertControllerContainedInViewController:] + 160 The exception trace is not leading to main() function but not pointing to any of the code line. I had used UIAlertController in the past versions to show the alerts but there is no code written in the current version code related to UIAlertController. Only from the latest version, this kind of crash started to surface. In the latest release, We have added a third party SDK and while implementing the SDK, we had added the Location and Bluetooth Permissions in Info.plist file. But as we don't want to use/track the Location and Bluetooth details from the app, the SDK team has disabled the Location and Bluetooth settings to not reflect in the tracked data. Is this behaviour creating any conflict with the UIAlertController and logging the crash? Because by default the OS tries to show the alert when the permissions exist in the plist file, but the alert will not come as the service is disabled on the SDK server settings. Is this creating any conflict and logging the crash. Please extend your help.
1
0
177
1w
UITableView dataSource is not set (17.4.1 (21E236) only)
#0 Thread NSInternalInconsistencyException UITableView dataSource is not set 0 CoreFoundation ___exceptionPreprocess + 164 20 UIKitCore ___swift_destroy_boxed_opaque_existential_1Tm + 12004 There is very little information about the call to the stack. Some of our iOS App users are suddenly experiencing a ** "UITableView dataSource is not set"** crash. I don't think it's a coincidence that these users are all 17.4.1 users.
1
0
128
1w
In Mac Catalyst, what would be the simplest way to hide the title bar but retain its double click functionality?
After adopting sidebar / split view controller support in Mac Catalyst, there are several UI side effects that make the default title bar stick out and look inconsistent. If I hide the title bar however, func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } #if targetEnvironment(macCatalyst) if let titlebar = windowScene.titlebar { titlebar.titleVisibility = .hidden titlebar.toolbar = nil } #endif } the ability to double click the top of the window to maximize it is lost. What would be the simplest approach to have both the hidden appearance, but keep the double click behavior?
0
0
148
2w
Full width UICollectionViewCells overlap during interface orientation rotations causing ugly animation
Preface Upon rotating the interface, the UICollectionViewCells overlap, generating an unpleasant animation that for sure can't be used in production. The code The code was executed on iPhone 6S (NN0W2TU/A A1688) with iOS 15.8.2. I could reproduce the issue on iPhone 15 Pro with iOS 17 on simulator as well. SelfConfiguringCell.swift: import UIKit protocol SelfConfiguringCell: UICollectionViewCell { static var reuseIdentifier: String { get } func configure(with image: String) } ISVImageScrollView.swift: Code here CarouselCell.swift: import UIKit import SnapKit class CarouselCell: UICollectionViewCell, SelfConfiguringCell, UIScrollViewDelegate { static var reuseIdentifier: String = "carousel.cell" internal var image: String = "placeholder" { didSet { self.imageView = UIImageView(image: UIImage(named: image)) self.scrollView.imageView = self.imageView } } let scrollView: ISVImageScrollView = { let scrollView = ISVImageScrollView() scrollView.minimumZoomScale = 1.0 scrollView.maximumZoomScale = 30.0 scrollView.zoomScale = 1.0 scrollView.contentOffset = .zero scrollView.bouncesZoom = true return scrollView }() var imageView: UIImageView = { let image = UIImage(named: "placeholder")! let imageView = UIImageView(image: image) return imageView }() func setImage(_ image: String) { self.image = image } func configure(with image: String) { self.setImage(image) self.scrollView.snp.makeConstraints { make in make.left.top.right.bottom.equalTo(contentView) } } override init(frame: CGRect) { super.init(frame: frame) contentView.backgroundColor = UIColor.black scrollView.delegate = self scrollView.imageView = self.imageView contentView.addSubview(scrollView) } required init?(coder: NSCoder) { fatalError("Cannot init from storyboard") } func viewForZooming(in scrollView: UIScrollView) -> UIView? { return self.imageView } } ViewController: import UIKit class ViewController: UICollectionViewController { var currentPage: IndexPath? = nil let images = ["police", "shutters", "depot", "cakes", "sign"] init() { let compositionalLayout = UICollectionViewCompositionalLayout { sectionIndex, environment in let absoluteW = environment.container.effectiveContentSize.width let absoluteH = environment.container.effectiveContentSize.height // Handle landscape if absoluteW > absoluteH { print("landscape") let itemSize = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1) ) let item = NSCollectionLayoutItem(layoutSize: itemSize) let groupSize = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1) ) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) let section = NSCollectionLayoutSection(group: group) return section } else { // Handle portrait print("portrait") let itemSize = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1.0), heightDimension: .absolute(absoluteW * 9.0/16.0) ) let item = NSCollectionLayoutItem(layoutSize: itemSize) let groupSize = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1.0), heightDimension: .absolute(absoluteW * 9.0/16.0) ) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) let section = NSCollectionLayoutSection(group: group) return section } } let config = UICollectionViewCompositionalLayoutConfiguration() config.interSectionSpacing = 0 config.scrollDirection = .horizontal compositionalLayout.configuration = config super.init(collectionViewLayout: compositionalLayout) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() collectionView.delegate = self collectionView.dataSource = self collectionView.isPagingEnabled = true // Register cell for reuse collectionView.register(CarouselCell.self, forCellWithReuseIdentifier: CarouselCell.reuseIdentifier) } override func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return self.images.count } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let reusableCell = collectionView.dequeueReusableCell(withReuseIdentifier: CarouselCell.reuseIdentifier, for: indexPath) as? CarouselCell else { fatalError() } let index : Int = (indexPath.section * self.images.count) + indexPath.row reusableCell.configure(with: self.images[index]) return reusableCell } } Notes I found a similar unanswered question here. I'm sure something can be done about it because if I switch to SwiftUI with a TabView, that according to SwiftUI Introspect documentation for TabViewWithPageStyleType, is using UICollectionView under the hood, I'm not getting that ugly animation anymore. Though I can't switch to SwiftUI to use TabView because on interface rotation it loses the page index (well known bug, see here), which probably is even trickier to workaround.
0
0
177
2w
UITableView indexPathsForVisibleRows get incorrect
I have a UITableView with 1 section and 3 rows, and each row is 1000 height, the UITableView height is 832, such as below: but when I click the right button, the visibleCells has 2 items(row-0 and row-1), but the indexPathsForVisibleRows only has 1 item(row-0). In my expectation, I set UITableView contentOffset with 168.8, the row-1 cell is visible. but indexPathsForVisibleRows does not correct. Well then, I try to read the assembly of indexPathsForVisibleRows, I found that the UITableView use _visibleBounds to compute indexPathsForVisibleRows, but the _visibleBounds.height is reduced by one when compute, why? the assembly code looks like below:
0
0
147
2w
Attach virtual keyboard to project in Adobe XD
I'm creating a slate pad for Ipad with several input fields to fill using Adobe XD. How can I obtain and attach a virtual keyboard to fill these input fields? I found a video with a similar concept but on Iphone: https://www.youtube.com/watch?v=O7tPI0VuKd4&list=PLWeIX-zcNnqII-nzviv_yxT2WNQRRYbiG&index=3 In this other link, the video mentions that the virtual keyboard was obtained from a UI kit that Apple provides. But I've looked and looked and I can't find a page to download this virtual keyboard. Any ideas? https://www.youtube.com/watch?v=rosf7-zVYjY&t=122s
0
0
223
2w