Post not yet marked as solved
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.
Post not yet marked as solved
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)
Post not yet marked as solved
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)
Post not yet marked as solved
If I use UIEditMenuInteraction to present an edit menu, it has a dismissMenu method that I can call to remove the menu when necessary.
When I use UITextInteraction, I get an edit menu automatically that is normally presented and dismissed at appropriate times. But sometimes I want to dismiss the menu myself, and I can't find a way to do that. Am I missing something? I was hoping to find that UITextInteraction inherited from UIEditMenuInteraction, or had some other way to access the underlying menu in order to dismiss it. But it seems that the menu must be a private part of the UITextInteraction implementation.
The particular case that I need to deal with is when I call resignFirstResponder. This seems to cause the keyboard to close and the insertion point and any selection to be hidden, but if an edit menu was shown then it remains visible (a ghost!). If anyone knows of an alternative to resignFirstResponder that will make UITextInteraction tidy up properly, that would also be useful to know.
Thanks for any suggestions!
Post not yet marked as solved
I have created a custom input field by conforming to UITextInput. It is setup to use UITextInteraction. Everything works very well. If the user taps on the custom field, the cursor (provided by UITextInteraction) appears. The user can type, select, move the cursor, etc.
But I'm stumped trying to get the cursor to appear automatically. With a normal UITextField or UITextView you simply call becomeFirstResponder(). But doing that with my custom UITextInput does not result in the cursor appearing. It only appears if the user taps on the custom field.
I don't know what I'm missing. I don't see any API in UITextInteraction that can be called to say "activate the cursor layer".
Does anyone know what steps are required with a custom UITextInput using UITextInteraction to activate the cursor programmatically without the user needing to tap on the custom field?
Post not yet marked as solved
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.
Post not yet marked as solved
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?
Post not yet marked as solved
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
Post not yet marked as solved
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?
Post not yet marked as solved
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 > 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.
Post not yet marked as solved
Hi, community:
I was trying to move from application(_:open:options:) (UIKit) to
onOpenURL(perform:) (SwiftUI). Maybe there's something that I'm missing.
In UIKit you can say to the system that you won't handle the URL then the app is not opened, but when I use onOpenURL(perform:) it is always opened. Is there any way to achieve the same behavior?
Thanks in advance.
Post not yet marked as solved
#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.
Post not yet marked as solved
I have a custom rotor that changes the skim speed of the skim forward/backward feature of my audio player. The rotor works, but it's always playing an end-of-list sound.
Here is the code:
// Member variables
private let accessibilitySeekSpeeds: [Double] = [10, 30, 60, 180] // seconds
private var accessibilitySeekSpeedIndex: Int = 0
func seekSpeedRotor() -> UIAccessibilityCustomRotor {
UIAccessibilityCustomRotor(name: "seek speed") { [weak self] predicate in
guard let self = self else { return nil }
let speeds = accessibilitySeekSpeeds
switch predicate.searchDirection {
case .previous:
accessibilitySeekSpeedIndex = (accessibilitySeekSpeedIndex - 1 + speeds.count) % speeds.count
case .next:
accessibilitySeekSpeedIndex = (accessibilitySeekSpeedIndex + 1) % speeds.count
@unknown default:
break
}
// Return the currently selected speed as an accessibility element
let accessibilityElement = UIAccessibilityElement(accessibilityContainer: self)
let currentSpeed = localizedDuration(seconds: speeds[accessibilitySeekSpeedIndex])
accessibilityElement.accessibilityLabel = currentSpeed + " seek speed"
UIAccessibility.post(notification: .announcement, argument: currentSpeed + " seek speed")
return UIAccessibilityCustomRotorItemResult(targetElement: accessibilityElement, targetRange: nil)
}
}
The returned accessibility element isn't read out, and instead an end-of-list sound is played. I can announce the change manually using UIAccessibility.post, but it still plays the end-of-list sound.
How can I prevent the rotor from playing the end-of-list sound?
Post not yet marked as solved
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?
Post not yet marked as solved
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.
Post not yet marked as solved
I am trying to save data files between runs of an iOS App from Xcode on a real iPad (not the simulator).
NSHomeDirectory gives me a different directory every time I run the app on the iPad (from XCode). I cannot write a file on one run and then retrieve it on the next run.
How do I get around this annoying problem?
Post not yet marked as solved
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:
Post not yet marked as solved
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
Post not yet marked as solved
When I use "[[UIApplication sharedApplication] setAlternateIconName:iconId completionHandler:nil];" to change the icon, the following exception is thrown. Please tell me how to deal with this problem
Error Domain=NSOSStatusErrorDomain Code=-54 "(null)" UserInfo={_LSLine=66,_LSFunction=-[_LSDIconCliend setAlternateIconName:forIdentifier:iconsDictionary:reply:]}
Post not yet marked as solved
Hi,
I have a UIBarButtonItem that I create with a UIMenu, and it's added to the navigation bar:
self.rightButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd menu: [self createMenuForAddItem]];
self.navigationItem.rightBarButtonItems = @[self.rightButton];
The menu shows fine when a user clicks on the bar button.
Now I want to also show this menu programmatically, for e.g if the user opens the app for the 5th time, the menu from the bar button item shows automatically, without the user having to explicitly press the button. How do I achieve this?