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

UIKit Documentation

Post

Replies

Boosts

Views

Activity

iOS 17 UIImageView tintColor issue
Applying color picked from UIColorPickerViewController to UIImageview's tintColor(a color having kCGColorSpaceModelRGB ColorSpace), then getting tintColor from that same UIImageView is always giving me gray color(a color having uiextendedgraycolorspace ColorSpace), this issue occured only in iOS 17 What can be the issue and please help me to solve it.
2
0
624
Nov ’23
SwiftUI Third Party Keyboard
Hello. I am developing an app that helps people with language issues communicate and for that I thought I could do a custom keyboard for them. I was wondering if there is a way of doing a 3rd party keyboard using SwiftUI (little to no UIKit) and if so, where can I find documentation/tutorials. I have looked with no success. Additionally, can we use a PKCanvasView inside of keyboards (ie, is there any restriction/policy)? I intend to use it so that users can draw the words they're looking for (I already have the model and know how to come up with the suggestions and everything) Thanks a lot!
0
0
644
Nov ’23
There are a lot of crashes in iOS17 and above
Hardware Model: iPhone15,3 Process: 甘草医生 [2305] Path: /private/var/containers/Bundle/Application/18AF408C-3B8B-4829-8621-4CCC16013765/甘草医生.app/甘草医生 Identifier: com.gancaoDoctor.doctor Version: 4.5.6 (45600) AppStoreTools: 15A240a AppVariant: 1:iPhone15,3:16 Code Type: ARM-64 (Native) Role: unknown Parent Process: launchd [1] Coalition: com.gancaoDoctor.doctor [1214] Date/Time: 2023-10-28 21:17:48.9795 +0800 Launch Time: 2023-10-28 21:10:32.0919 +0800 OS Version: iPhone OS 17.1 (21B74) Release Type: User Baseband Version: 2.10.03 Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000524f185b80 Exception Codes: 0x0000000000000002, 0x000000524f185b80 VM Region Info: 0x524f185b80 is in 0x524f184000-0x7000000000; bytes after start: 7040 bytes before end: 127522022527 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL commpage (reserved) 1000000000-524f184000 [265.2G] ---/--- SM=NUL ...(unallocated) ---> GPU Carveout (reserved) 524f184000-7000000000 [118.8G] ---/--- SM=NUL ...(unallocated) UNUSED SPACE AT END Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 libobjc.A.dylib 0x00000001936433cc class_getMethodImplementation + 56 (objc-class.mm:702) 1 Foundation 0x000000019a230c74 _NSKVONotifyingOriginalClassForIsa + 32 (NSKeyValueObserverNotifying.m:950) 2 Foundation 0x000000019a230924 _NSKeyValueObservationInfoGetObservances + 280 (NSKeyValueObservationInfo.m:820) 3 Foundation 0x000000019a22fddc NSKeyValueWillChangeWithPerThreadPendingNotifications + 232 (NSKeyValueObserving.m:1199) 4 QuartzCore 0x000000019c9647a8 CA::Display::Display::update() + 2564 (CADisplay.mm:2904) 5 QuartzCore 0x000000019c9c8658 invocation function for block in ensure_displays() + 136 (CADisplay.mm:6040) 6 libsystem_notify.dylib 0x00000001c5efdbec ___notify_dispatch_local_notification_block_invoke + 72 (notify_client.c:2044) 7 libdispatch.dylib 0x00000001a3240250 _dispatch_block_async_invoke2 + 148 (queue.c:555) 8 libdispatch.dylib 0x00000001a3231300 _dispatch_client_callout + 20 (object.m:561) 9 libdispatch.dylib 0x00000001a323f998 _dispatch_main_queue_drain + 984 (queue.c:7813) 10 libdispatch.dylib 0x00000001a323f5b0 _dispatch_main_queue_callback_4CF + 44 (queue.c:7973) 11 CoreFoundation 0x000000019b2ab20c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780) 12 CoreFoundation 0x000000019b2a7f18 __CFRunLoopRun + 1996 (CFRunLoop.c:3149) 13 CoreFoundation 0x000000019b2a7668 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420) 14 GraphicsServices 0x00000001de6725ec GSEventRunModal + 164 (GSEvent.c:2196) 15 UIKitCore 0x000000019d6c4294 -[UIApplication _run] + 888 (UIApplication.m:3685) 16 UIKitCore 0x000000019d6c38d0 UIApplicationMain + 340 (UIApplication.m:5270) 17 甘草医生 0x00000001049b64a8 main + 168 (main.m:22) 18 dyld 0x00000001bdcfadcc start + 2240 (dyldMain.cpp:1269)
0
0
325
Nov ’23
-[UINavigationController pushViewController:transition:forceImmediate:]
Fatal Exception: NSInvalidArgumentException <UIPrintPanelNavigationController: 0x144010a00> is pushing the same view controller instance (<UIPrinterBrowserViewController: 0x142854400>) more than once which is not supported and is most likely an error in the application : com.myapp.myapp Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0xec870 __exceptionPreprocess 1 libobjc.A.dylib 0x2bc00 objc_exception_throw 2 UIKitCore 0xcb284 -[UINavigationController pushViewController:transition:forceImmediate:] 3 UIKitCore 0xca398 -[UINavigationController pushViewController:animated:] 4 PrintKitUI 0x45024 -[UIPrintPanelNavigationController pushViewController:animated:] 5 UIKitCore 0x129b78 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] 6 UIKitCore 0x129680 -[_UIViewControllerTransitionContext _runAlongsideCompletions] 7 UIKitCore 0x128d10 -[_UIViewControllerTransitionContext completeTransition:] 8 UIKitCore 0x7a3d48 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_5 9 UIKitCore 0x84a38 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ 10 UIKitCore 0x841d0 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] 11 UIKitCore 0x83848 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 12 UIKitCore 0x65aa4 -[UIViewAnimationState animationDidStop:finished:] 13 UIKitCore 0x65bb8 -[UIViewAnimationState animationDidStop:finished:] 14 QuartzCore 0x72098 run_animation_callbacks(void*) 15 libdispatch.dylib 0x4300 _dispatch_client_callout 16 libdispatch.dylib 0x12998 _dispatch_main_queue_drain 17 libdispatch.dylib 0x125b0 _dispatch_main_queue_callback_4CF 18 CoreFoundation 0x3720c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 19 CoreFoundation 0x33f18 __CFRunLoopRun 20 CoreFoundation 0x33668 CFRunLoopRunSpecific 21 GraphicsServices 0x35ec GSEventRunModal 22 UIKitCore 0x22c2b4 -[UIApplication _run] 23 UIKitCore 0x22b8f0 UIApplicationMain 24 MyApp 0x4a940 main + 14 (main.m:14) 25 ??? 0x1ac55adcc (Missing) I found this crash in Firebase crashlytics. This is device info Model:iPad Air (5th generation) Version:17.1.1 Orientation:Landscape Please help me to findout the root cause of the crash and possible solution. I have tried to reprduce the crash but didn't reproduce.
1
0
953
Nov ’23
UIContentUnavailableConfiguration and Accessibility VoiceOver
I have been implementing UIContentUnavailableConfigurations in my app and I've noticed that when contentUnavailableConfiguration changes via func updateContentUnavailableConfiguration(using state: UIContentUnavailableConfigurationState) VoiceOver does not focus on the content of the UIContentUnavailableConfiguration. It either focuses on the NavBar back button or on a subview behind the content unavailable overlay. I've looked at using UIAccessibility.post(notification: UIAccessibility.Notification.screenChanged, argument: nil) but I can't find an accessibility element to provide as an argument. Is there a way to focus VoiceOver on the UIContentUnavailableView when contentUnavailableConfiguration changes?
0
0
293
Nov ’23
*** Assertion failure in -[_UISystemBackgroundView _internalSubviewsOfType:], _UISystemBackgroundView.m:133
Our application was working fine in iOS 16, but after upgrading to iOS 17.1.1, we see a 100% reproducible crash when generating a cell in the [UITableViewDataSource tableView: cellForRowAtIndexPath:] callback for a particular table. I've only found a single table so far where it crashes. This is the line of code where it crashes: ItemContentTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath]; The crash occurs on the first call. Since it only crashes in this one table, I imagine it's somehow related to the particulars of the cell content layout, but as far as I can see, there's nothing spectacular going on there. Any ideas?? Thanks.
4
0
749
Nov ’23
Share submenu in Mac Catalyst and UICommandTagShare
With Mac Catalyst, in Big Sur and Monterey, you could use UICommandTagShare as the property list for a UICommand in combination with activityItemsConfiguration and itemProvidersForActivityItemsConfiguration to allow a "Share" submenu to appear in a menu in your app (for instance, under the File menu like many other apps). Starting in Ventura, this submenu no longer appears with that same code, and instead the UICommandTagShare command in the menu now just displays "Share" with no submenu, which triggers a UIActivityViewController to appear in the main window. Is there any way to still allow a Share submenu to work in Ventura and beyond with Mac Catalyst? Thanks so much for any help!
1
1
572
Dec ’23
Changing presentation style crashes app
Hello! I've been digging into this for a little bit now, and am hitting something of a wall. Our app is crashing occasionally, and googling the crash yields literally 0 results. Tl;dr: Something related to adaptivePresentationStyle(for:traitCollection:) is resulting in our app crashing. Context In our app, we have a custom UIPresentationController that we use to present a small sheet of content overlaying other app content - similar to a UISheetPresentationController with a medium-ish size. So we have a custom UIViewController to present, and it conforms to the UIAdaptivePresentationControllerDelegate protocol. We also have custom present and dismiss animators. The crash However, we seem to be running into a really odd crash. I've attached a crash report as well, but here's what one sees in xcode on reproducing the crash: The _computeToEndFrameForCurrentTransition block is nil inside the _transitionViewForCurrentTransition block, value of outerStrongSelf currently : <XxxYyyyyyZzz.PopupPresentationController: 0x12d017a40>. This most likely indicates that an adaptation is happening after a transtion cleared out _computeToEndFrameForCurrentTransition. Captured debug information outside block: presentationController : <XxxYyyyyyZzz.PopupPresentationController: 0x12d017a40> presentedViewController : <XxxYyyyyyZzz.SomeViewController: 0x12d03a690> presentingViewController : <UINavigationController: 0x12a817400> 2023-09-25_08-02-33.6523_-0500-7d355cd4a86427213389765ef070a777c4b4aaa3.crash Whenever we present one of these view controllers, things work just fine. When we try to present another one though, if someone is aggressively changing the phone orientation, the app crashes. This crash occurs somewhere in between dismissing the old VC and presenting the new one. It occurs before I ever hit any breakpoints in the "present" animator for the second view controller. I've narrowed things down a bit, and by commenting out our implementation of adaptivePresentationStyle(for:traitCollection:), the crash can't be reproduced anymore. The downside there being that the app no longer functions how we want it to. Our definition of that function (which causes crashes) looks like this: public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle { guard forceUsingFullScreenIfCompact else { return .none } return traitCollection.verticalSizeClass == .compact ? .overFullScreen : .none } A bit more testing, and it seems like if that function returns the same thing consistently, nothing crashes. Are we not allowed to put conditional logic in this function? In the crash, we can see that it occurs due to a failing assertion internal to UIPresentationController: Last Exception Backtrace: 0 CoreFoundation 0x1afa28cb4 __exceptionPreprocess + 164 (NSException.m:202) 1 libobjc.A.dylib 0x1a8abc3d0 objc_exception_throw + 60 (objc-exception.mm:356) 2 Foundation 0x1aa1b2688 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 172 (NSException.m:251) 3 UIKitCore 0x1b1d05610 __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 2588 (UIPresentationController.m:1594) 4 UIKitCore 0x1b21f1ff4 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 + 300 (UIPresentationController.m:1228) The question This all leads us to wonder if we're doing something wrong, or if there could be a bug in one of the iOS APIs that we're consuming. Thus, posting here. Does anyone have any insight into how this could be occurring, or has seen this before and has ideas? Thanks! Miscellaneous info We target iOS 14+ We've seen this issue in debug and release builds from Xcode 14 and 15 We see the issue on users with iOS 15+, though it could be occurring on 14 in just incredibly low numbers This is a re-post of https://developer.apple.com/forums/thread/738257, because I accidentally closed that out as resolved
4
2
800
Dec ’23
Help with crash in objc_msgSend (no app code in stack trace)
Hello, I am attempting to track down a crash that isn't giving me a lot of information (crash log included below). Here is what I know so far: According to Apple documentation, a crash in objc_msgSend is due to a zombie object. So I have been trying to recreate the crash with zombies enabled, without success. The address of the object being messaged is 0x0000000000000010, a suspect value. It's always 0x10, across thousands of crash reports with slightly differing stack traces and circumstances. That makes me wonder if the runtime is trying to tell me something with that address, but I have been unable to find any documentation to that effect. We have internal analytics that suggest that the crash always happens after the user activates the system PIP video player, and usually also after backgrounding the app. It is also common (though not universal) that the crash occurs after the user has paused the video (and sometimes resumed it). This post is a bit of a Hail Mary; I'm hoping that maybe someone on here will see something I missed, because I have exhausted most of my own avenues of investigation. Many thanks for any help you can provide. 2023-11-30_07-16-00.4347_-0800-ffd5dc1a3d2ca628e1761ccfec5fe79f223d099e.crash
3
0
1.8k
Dec ’23
MFMessageComposeViewController cannot send special characters via iOS 17
I have a text in the application that comes with special characters (the text is written in French) that I want to send using MFMessageComposeViewController. I define the text in the body field: messageComposeVC.body = body and call to present the message compose like that : UIApplication.topViewController()?.present(messageComposeVC, animated: true, completion: nil) The message/imessage open and display the preview with the text i defined. But, since the upgrade of the iPhone to ios 17 it stopped working, when i send the message the message was not send and I received a message that the message failed. I also tested on ios 16 - it works great. Any idea how i can fix it?
0
0
851
Dec ’23
How to disable scroll animation for UITextField?
Yes, I mean UITextField. Howdy, Is there a way to disable the animation that occurs to a UITextField with long content after it becomes first responder? Specifically the one that sort of slow scrolls to the end of the content. Here's a video of the animation I am trying to describe https://www.youtube.com/watch?v=9l2tUrxW_qY . Notice how the textfield transitions from "a" to "." as it moves to the end of the content? Ideally, I would like the UITextField to simply appear on the screen like it does in the final frame of the animation, showing the final part of the content. Thanks, smkuehnhold
0
0
406
Dec ’23
How to handle UIPhysicalKeyboardEvent?
I'm trying to improve our application to receive and handle events from a bluetooth keyboard. To intercept incoming events I use sendEvent: method. But I get a different event type for a different key. For example when I press 'Esc' key I get an event type is UIEventTypePresses (and event is a instance of UIPressesEvent class) but when I press 'ArrowUp' key I get an event type is 4 (there is no enum value for that number) and event is a instance of UIPhysicalKeyboardEvent class. In the first case I found a documentation of UIPressesEvent and I can implement handler for it. But for the second case I didn't find any documentations of UIPhysicalKeyboardEvent nether in the online documentation nor in the Xcode help. How can UIPhysicalKeyboardEvent events be handled? Is the any documentation for that? My target OS is tvOS 17.1
1
0
585
Dec ’23
UIKit Document App -- adding a toolbar
I've had to ditch the SwiftUI app lifecycle due to this issue: https://developer.apple.com/forums/thread/742580 After creating a new UIKit document app as a test, it doesn't have a toolbar when opening the document. How can I add one along the lines of https://developer.apple.com/wwdc22/10069 ? The UIDocumentViewController isn't already embedded in a UINavigationController it seems. To reproduce: New Project -> iOS -> Document App. Select Interface: Storyboard. Add an empty "untitled.txt" resource to the project. Change the first line in documentBrowser(_:,didRequestDocumentCreationWithHandler:) to let newDocumentURL: URL? = Bundle.main.url(forResource: "untitled", withExtension: "txt")
2
0
508
Dec ’23
Why UIActivityViewController navigationBar backgroundColor is clear?
Under iOS 17, I need to set view.backgroundColor when using UIActivityViewController, otherwise the navigationBar will be transparent. (iOS 17 does not have this problem) I have checked many tutorial examples but this situation is not mentioned. Is there any implementation missing from my code? Sample Code: let sharedURL = URL(string: "...")! let activityVC = UIActivityViewController(activityItems: [sharedURL], applicationActivities: nil) present(activityVC, animated: true) Sample Image:
1
0
308
Dec ’23
Changing font in CollectionView UIIndexBarAccessoryView
I have a 600 item Collection view for which I implemented a quick access section Index. The implementation uses the usual: indexTitles(for collectionView) and CollectionView(indexPathForIndexTitle: title: at:) All is well, except that the collection titles are in a foreign language (latinized Coptic) and 3 of the 25 title glyphs are not in the SystemFont, so the index is drawn with these titles as question marks in boxes. The problem glyphs are "Ꜣ"(unicode A722), "꟣"(A7E3), and "Ꜥ"(A725) I drilled down on the subviews of the CollectionView and found I could access the index using: let subviews = myCollectionView.subviews if let indexView = subviews.first(where: {String(describing: type(of: $0))=="UIIndexBarAccessoryView"}) { print(indexView) } Examining the contents of this UIIndexBarAccessoryView (which seems to be Private), it contains a _visualStyle property object which holds a _font. How can I "legally" change the font for the indexBarAccessory to one that has the required glyphs? The rest of the App requires the local language to be English(US)
0
0
332
Dec ’23
black screen after switching to UIKit app lifecycle
I had to switch from the SwiftUI app lifecycle to the UIKit lifecycle due to this issue: https://developer.apple.com/forums/thread/742580 When I switch to UIKit I get a black screen on startup. It's the inverse of this issue: https://openradar.appspot.com/FB9692750 For development, I can work around this by deleting and reinstalling the app, but I can't ship an app that results in a black screen for users when they update. Anyone know of a work-around? I've filed FB13462315
3
2
940
Dec ’23
SwiftUI TabBar Icons Disappearing
I have a UIKit tabbar view that contains three views, one of which is a UIViewControllerRepresentable wrapper around a UIKit view controller. Everything works fine except when that wrapped view is visible, the tab bar icons for the other two views disappear. Tapping within their bounds still works to select those views as expected, and they’re even visible in screenshots and in the debug view of the view hierarchy (they also display normally when running the iPad version of the app on Mac), so I’m not sure where to turn except perhaps a bug report. Is this a known issue when running UIKit views within a SwiftUI TabBar or where should I look next?
2
0
732
Dec ’23