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

UIKit Documentation

Post

Replies

Boosts

Views

Activity

Crash on [UITextField inputAssistantItem] + 68
I have a crash on 19 [UITextField inputAssistantItem] + 68 It is running on a Simulator, is this related? Details: ========= code in app ================================ numberTextField = CursorInCenterTextField() numberTextField.listener = self numberTextField.delegate = self numberTextField.textAlignment = .left numberTextField.adjustsFontSizeToFitWidth = true numberTextField.isUserInteractionEnabled = true numberTextField.inputView = UIView() numberTextField.inputAssistantItem.leadingBarButtonGroups = [] numberTextField.inputAssistantItem.trailingBarButtonGroups = [] numberTextField.font = UIFont.systemFont(ofSize: 24.0, weight: .medium) numberTextField.autocorrectionType = .no numberTextField.returnKeyType = .search ========= crash stack from ips file ======================== Incident Identifier: 50AF117D-546E-409E-8915-6E4607C83BC0 CrashReporter Key: 4AB5D894-3E17-F998-4B64-F931D05DC65D Hardware Model: Macmini9,1 Process: Glip [47003] Path: /Users/USER/Library/Developer/CoreSimulator/Devices/83049BCF-16F7-481C-BE83-58727242A065/data/Containers/Bundle/Application/82E219BC-96B5-4A0F-AB20-D068A88C792F/Glip.app/Glip Identifier: com.glip.mobile.rc Version: 25.1.10 (132) Code Type: X86-64 (Native(?)) Role: Foreground Parent Process: launchd_sim [38628] Coalition: com.apple.CoreSimulator.SimDevice.83049BCF-16F7-481C-BE83-58727242A065 [1342] Date/Time: 2024-12-04 22:47:10.4249 +0800 Launch Time: 2024-12-04 22:47:02.4577 +0800 OS Version: macOS 14.5 (23F79) Release Type: User Baseband Version: None Report Version: 104(?) Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x00000001b3531d10 Exception Codes: 0x0000000000000001, 0x00000001b3531d10 Exception Note: EXC_CORPSE_NOTIFY(?) VM Region Info: 0x1b3531d10 is not in any region. Bytes after previous region: 3427601 Bytes before following region: 176880 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL Rosetta Generic 1b31ec000-1b31ed000 [ 4K] rw-/rwx SM=PRV ---> GAP OF 0x370000 BYTES Rosetta Generic 1b355d000-1b355e000 [ 4K] rw-/rwx SM=PRV Termination Reason: SIGNAL;[11] Segmentation fault: 11 Terminating Process: exc handler [47003] Triggered by Thread: 0 Kernel Triage: None Thread 0 name: com.apple.main-thread Thread 0 Crashed: 0 None 0x11e1e0144 0x0 + 4800250180 1 CoreUI 0x14fa08817 -[CUIStructuredThemeStore renditionWithKey:usingKeySignature:] + 406 2 CoreUI 0x14fa3e8ac -[CUICatalog _storageRefForRendition:representsODRContent:] + 94 3 CoreUI 0x14fa3b244 -[CUICatalog namedVectorGlyphWithName:scaleFactor:deviceIdiom:layoutDirection:glyphContinuousSize:glyphContinuousWeight:glyphPointSize:appearanceName:locale:] + 1909 4 CoreUI 0x14fa3b3a5 -[CUICatalog namedVectorGlyphWithName:scaleFactor:deviceIdiom:layoutDirection:glyphSize:glyphWeight:glyphPointSize:appearanceName:locale:] + 74 5 UIKitCore 0x167c4f99c __78-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke_2 + 201 6 UIKitCore 0x167c51fce __88-[_UIAssetManager _performLookUpObjectForTraitCollection:outNamedLookup:objectAccessor:]_block_invoke + 79 7 UIKitCore 0x16713340e -[UITraitCollection _enumerateThemeAppearanceNamesForLookup:] + 215 8 UIKitCore 0x167c51f3d -[_UIAssetManager _performLookUpObjectForTraitCollection:outNamedLookup:objectAccessor:] + 172 9 UIKitCore 0x167c520c0 -[_UIAssetManager _lookUpObjectForTraitCollection:objectAccessor:] + 40 10 UIKitCore 0x167c4f709 __78-[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:]_block_invoke + 849 11 UIKitCore 0x167c4f137 -[_UIAssetManager imageNamed:configuration:cachingOptions:attachCatalogImage:] + 291 12 UIKitCore 0x167c5001d -[_UIAssetManager imageNamed:configuration:] + 224 13 UIKitCore 0x1670c1b87 +[UIImage _systemImageNamed:withConfiguration:allowPrivate:] + 297 14 UIKitCore 0x167ae8cc0 +[UIAssistantBarButtonItemProvider configuredSymbolImageWithName:size:keyboardLanguageCode:] + 585 15 UIKitCore 0x167ae747e +[UIAssistantBarButtonItemProvider barButtonItemForAssistantItemStyle:target:forcePlainButton:] + 2850 16 UIKitCore 0x167ae90f1 +[UIAssistantBarButtonItemProvider defaultSystemLeadingBarButtonGroupsForItem:] + 206 17 UIKitCore 0x167ae9935 +[UIAssistantBarButtonItemProvider systemDefaultAssistantItem] + 55 18 UIKitCore 0x167719194 -[UIResponder(UIResponderInputViewAdditions) inputAssistantItem] + 67 19 UIKitCore 0x167b67898 -[UITextField inputAssistantItem] + 68 20 Glip 0x105915dbc BaseDialPadViewController.setupTopContainerViewConstraintAndSubViews() + 780 21 Glip 0x105917869 BaseDialPadViewController.setupContentViewForM1X() + 2681 22 Glip 0x105915781 BaseDialPadViewController.setupUI() + 193 ........
0
0
247
Dec ’24
TextKit 2 : replaceContents(in:with:) is not working
I have NsTextList and it has [NsTextListElement], I want to replace an NsTextListElement with other element like NsTextParagraph or NstextListElement or an AttributedString. For some reason the below method is not working at all. And I couldn't find any alternate way of replacing the elements textLayoutManager.replaceContents(in: element.elementRange, with: NSAttributedString(string: "happy"))
2
0
345
Dec ’24
In 18.2 beta, WKWebView consumes `buildMenu`
I have a view controller that is hosing a WKWebView. My view controller overrides buildMenu(with builder: UIMenuBuilder), and prior to the beta, this was called reliably. However under 18.2 beta 4, it is not called at all, despite no code changes on my part. Things I've tried: Ensured that my responder chain is set up correctly. Walked through the debugger via a symbolic breakpoint on [UIResponder buildMenuWithBuilder:] to understand that the web view is the last object to get a buildMenuWithBuilder message. Any feedback or commiseration would be appreciated.
3
0
427
Dec ’24
Xamarin application crashing in iOS 18.1
My xamarin application running fine in iOS 17 and below versions. but in iOS 18 and above when I open application and then when I use it for few min it gets crashed automatically and does not even show any crash report in mobile. When I checked the console logs in XCode then I found out that One error is logging more than 700 times in a sec. that is why the application is crashing. I will attach the error below. Modifying properties of a view's layer off the main thread is not allowed: view <Xamarin_Forms_Platform_iOS_FrameRenderer: 0x7f9605e5e7a0> with nearest ancestor view controller <Xamarin_Forms_Platform_iOS_GroupableItemsViewController_1: 0x7f9605f96dc0>; backtrace: ( 0 UIKitCore 0x0000000152d29c00 -[UIView(UIKitManual) _raiseExceptionForBackgroundThreadLayerPropertyModification] + 453 1 UIKitCore 0x0000000152d2a188 -[UIView(UIKitManual) actionForLayer:forKey:] + 609 2 QuartzCore 0x0000000126f731da -[CALayer actionForKey:] + 151 3 QuartzCore 0x0000000126f7a425 ZN2CA5Layer12begin_changeEPNS_11TransactionEjP11objc_objectRS4 + 199 4 QuartzCore 0x0000000126f7ead8 _ZN2CA5Layer6setterEj12_CAValueTypePKv + 974 5 QuartzCore 0x0000000126f727e9 -[CALayer setOpacity:] + 49 6 Leadrat.Mobile.Forms.iOS 0x0000000101122fc9 xamarin_dyn_objc_msgSend + 217 7 ??? 0x00000001a315f176 0x0 + 7031091574 8 ??? 0x00000001b312d0bb 0x0 + 7299322043 9 ??? 0x000000019d76712b 0x0 + 6936752427 10 Mono 0x000000010b9b70b5 mono_jit_runtime_invoke + 1621 11 Mono 0x000000010bbac1e8 mono_runtime_invoke_checked + 136 12 Mono 0x000000010bbb1c9d mono_runtime_delegate_try_invoke + 157 13 Mono 0x000000010bbd0957 start_wrapper_internal + 647 14 Mono 0x000000010bbd06ae start_wrapper + 62 15 libsystem_pthread.dylib 0x000000012a21018b _pthread_start + 99 16 libsystem_pthread.dylib 0x000000012a20bae3 thread_start + 15
1
0
288
Dec ’24
Does the videoDeviceNotAvailableWithMultipleForegroundApps Interruption Occur on iPhones?
Hello, I am developing a service using capture sessions. I have a question concerning something curious I've noticed. Occasionally, I've been informed that the capture session stops working. Upon investigation, I found records of the videoDeviceNotAvailableWithMultipleForegroundApps interruption on the devices. From what I've looked up in the documents, it seems to occur due to multitasking capabilities, but I'm wondering if there are any specific scenarios where this happens on iPhone devices? Here is the relevant documentation link: https://developer.apple.com/documentation/avfoundation/avcapturesession/interruptionreason/videodevicenotavailablewithmultipleforegroundapps I suspect it might have something to do with Picture-in-Picture (PIP) mode, but when I developed and tested a direct video streaming PIP, the issue did not occur. Does anyone have insights on this matter or related experiences they could share?
0
0
278
Dec ’24
UIDocumentPickerViewController directoryURL no longer opening correct folder
Since iOS 18, I have gotten user reports that the UIDocumentPickerViewController directoryURL is no longer opening the correct folder. Instead it is just loading the root directory of the Files app/iCloud files. Did something change in iOS 18 that I need to account for? Not all users are having this issue, but some are and they are frustrated because a major feature of my app was to allow users to save files at the ubiquityURL. I use the following to get the path: NSURL *rootDirectory = [[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil] URLByAppendingPathComponent:[NSString stringWithFormat:@"Documents/Photos/%@", folderName]]; Is there something that I need to do differently now in iOS 18 to prevent this from happening?
0
0
277
Dec ’24
siri caused the app to crash
Some users experience this kind of crash: NSInternalInconsistencyException:Use of the class INVocabulary requires the entitlement com.apple.developer.siri. Make sure you have enabled the Siri capability in your Xcode project. During app startup, calling the following code causes a crash: INVocabulary *vocabulary = [INVocabulary sharedVocabulary]; But our project definitely has siri configured to be available. Now that we can't figure it out, is it a bug in the system?
1
0
249
Nov ’24
UIDocumentPickerViewController fullScreen not working
When I present a UIDocumentPickerViewController I want it to occupy the fullscreen but it never displays as fullscreen The modalPresentationStyle seems to have no effect no matter what I set it to Running the code with DispatchQueue.main.async did not help either Here is the code Anybody got any suggestions? `@objc private func plusButtonPressed() { DispatchQueue.main.async { let picker = UIDocumentPickerViewController(documentTypes: [kUTTypeData as String], in: .import) picker.delegate = self picker.modalPresentationStyle = .fullScreen self.present(picker, animated: true) } }`
0
0
333
Nov ’24
Typographic question for space character
In this UIKit app, I have to display numbers (from 1 to 100), in a label., on several lines, with 8 numbers on each line. Order is computed by the app for a specific purpose. The numbers are separated by space. Label font is Helvetica Neue 15.0. I want to get them aligned vertically. So, I have a padding so that they are all the same length of 4. Problem: the space have smaller width (half in fact) than digits, so alignment is disrupted: Of course, I can use fixed width fonts (like Menlo), but I've not found one that fits (the zero is barred, which is not looking great in the app). I have tried using class func monospacedDigitSystemFont( ofSize fontSize: CGFloat, weight: UIFont.Weight ) -> UIFont and apply to label.text. To no avail as it modifies only digits, not space char. I have found a workaround, padding with 2 spaces instead of one, but is there another solution ? So I am looking for a space character that would have the same width as a digit. There existe thin space (https://en.wikipedia.org/wiki/Whitespace_character) but not larger space. Does it exist ?
5
0
433
Nov ’24
UIDocumentPickerViewController: open to specific folder
Hi, With UIDocumentPickerViewController, there is a directoryURL property that says we can use to 'specify the starting directory for the document picker'. But it's not clear how to get the directory of a folder in iCloud Drive / Files app. How can I get the 'root' directory for a user's iCloud Drive or Dropbox folder, or the Downloads folder on their device, that I could pass to this directoryURL to make it easier for the user to pick their files? Thanks.
0
0
284
Nov ’24
prefersPointerLocked not worked properly if run on MacOS environment
Hi community. I am trying to adopt my first person shooter iOS game for running on MacOS environment. I need to lock the pointer when I enter battle mode, and unlock in lobby. On iOS all works fine (with mouse and keyboard) - pointer locks and unlocks according to my commands. However, on MacOS I faced the following behavior: after switching the pointer lock state and setNeedsUpdateOfPrefersPointerLocked invocation, the pointer does not locked immediately. To enable pointer lock, the user must click in the window. I checked the criteria listed in documentation: I do have fullscreen mode, I monitor UISceneActivationState and can confirm it is UISceneActivationStateForegroundActive, I do not use MacCatalyst (it is disabled in app's capabilities). However pointer locks only after click on window, which is weird. Can someone confirm that this is the exact behaviour as designed by Apple developers, or am I doing anything wrong. I have read the note: "Bringing an app built with Mac Catalyst to the foreground doesn’t immediately enable pointer lock. To enable pointer lock, the user must click in the window. To exit pointer lock, users can use Command-tab to switch to another app, or using Command-tilde.", but again, I don't use MacCatalyst. Any hints are highly appreciated! Best regards. refs: https://developer.apple.com/documentation/apple-silicon/running-your-ios-apps-in-macos https://developer.apple.com/documentation/uikit/uiviewcontroller/3601235-preferspointerlocked?language=objc
1
0
310
Nov ’24
Diffable Data Source Warning: Non-Thread Confined Updates
Hello, I’ve encountered a warning while working with UITableViewDiffableDataSource. Here’s the exact message: Warning: applying updates in a non-thread confined manner is dangerous and can lead to deadlocks. Please always submit updates either always on the main queue or always off the main queue - view=&lt;UITableView: 0x7fd79192e200; frame = (0 0; 375 667); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = &lt;NSArray: 0x600003f3c9f0&gt;; backgroundColor = &lt;UIDynamicProviderColor: 0x60000319bf80; provider = &lt;NSMallocBlock: 0x600003f0ce70&gt;&gt;; layer = &lt;CALayer: 0x6000036e8fa0&gt;; contentOffset: {0, -116}; contentSize: {375, 20}; adjustedContentInset: {116, 0, 49, 0}; dataSource: &lt;TtGC5UIKit29UITableViewDiffableDataSourceOC17ArticleManagement21DiscardItemsViewModel17SectionIdentifierSS: 0x600003228270&gt;&gt; OS: iOS Version: iOS 17+, Xcode Version: 16.0, Frameworks: UIKit, Diffable Data Source, View: UITableView used with a UITableViewDiffableDataSource. Steps to Reproduce: Using a diffable data source with a table view. Applying snapshot updates in the data source from a main thread. Warning occurs intermittently during snapshot application. Expected Behavior: The snapshot should apply without warnings, provided the updates are on a main thread. Actual Behavior: The warning suggests thread safety issues when applying updates on non-thread-confined queues. Questions: Is there a recommended best practice to handle apply calls in diffable data sources with thread safety in mind? Could this lead to potential deadlocks if not addressed? Note :- I confirm I am always reloading / reconfiguring data source on main thread. Please find the attached screenshots for the reference. Any guidance or clarification would be greatly appreciated!
0
0
403
Nov ’24
UIKit Internal bug: Unbalanced call to _endOcclusion, please file a feedback report with any information you have that helps reproduce this bug!
Hi, I'm getting a bug in SwiftUI when dismissing a sheet and then hitting the back button or swiping to go back in a navigation stack. This issue happens inconsistently but causes undesirable behavior where the screen freezes in a partially dismissed state but does not crash. A user can click on another tab and return back and the view will have completed dismissal. The error seems more likely to happen if the time between dismissing the sheet and navigating backwards is minimal. I've experimenting using different forms of navigation, NavigationStack using NavigationPaths and NavigationDestinations, NavigationLinks, NavigationViews, etc. The issue persists. Is there a nice fix or intended fix to this issue coming soon? Thank you!
1
0
257
Nov ’24
Potential Issue in "Display Distinct Layouts Per Section" Documentation Example
Hi everyone, I was exploring the Display Distinct Layouts Per Section section of the Apple documentation and noticed a potential issue in the example code provided. Specifically, in the createLayout method of the TwoColumnViewController in the sample project, the item size appears to be incorrectly described. The documentation states that the item size is ignored because the items are organized in columns, but in practice, the size is considered. When running the sample project without any modifications, the layout doesn't behave as described or expected. Here’s what I observed: The items are not displayed as intended in a two-column layout. Modifying the item size explicitly affects the layout, contrary to the documentation's claim that the size is ignored. This seems to be a mismatch between the documentation and the actual implementation. Could this be clarified or corrected? Has anyone else encountered this issue? If so, are there any recommended adjustments to the sample code to achieve the intended layout? Thanks in advance for any insights or updates on this! https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/implementing_modern_collection_views#4461906
0
2
207
Nov ’24
[SWIFT] Accessing and controlling @IBOutlet variables from other ViewControllers.
I am having trouble accessing and controlling @IBOutlet variables from other ViewControllers. More specifically, I want to control that @IBOutlet variable based on real-time changes in the variable value of another ViewController. Control is possible in the viewcontainer that contains the @IBOutlet variable, but when trying to control it from another viewcontainer, the message "Thead1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value" appears. Is there any possible way to do it? I think this will be difficult since thread1 in the error message means the main thread, so I tried to create a thread in the viewcontainer that has the @IBOutlet variable and access the variable of another viewcontainer to control the @IBOutlet variable inside the thread, but in this case, the variable value of the other viewcontainer that changes in real time is fixed to the value at the moment the thread is created, and the value that changes in real time after that cannot be retrieved. And I don't think using threads for this purpose is a good way. I sincerely ask for help from all the experts. If I can solve this, it will be easy to create the rest of the app structure. Sincerely !
1
1
269
Nov ’24
shouldAutomaticallyForwardAppearanceMethods returns NO by default in UITabBarController, but documentation states YES
Hi all, I’ve been facing a behavior issue with shouldAutomaticallyForwardAppearanceMethods in UITabBarController. According to Apple’s documentation, this property should default to YES, which means that the appearance lifecycle methods (like viewWillAppear and viewDidAppear) should be automatically forwarded to child view controllers. However, in my current development environment, I’ve noticed that shouldAutomaticallyForwardAppearanceMethods returns NO by default in UITabBarController, and this is causing some issues with lifecycle management in my app. I even tested this behavior in several projects, both in Swift and Objective-C, and the result is consistent. Here are some details about my setup: I’m using Xcode 16.0 with iOS 16.4 Simulator. I’ve tested the behavior in both a new UIKit project and a simple SwiftUI project that uses a UITabBarController. Even with a clean new project, the value of shouldAutomaticallyForwardAppearanceMethods is NO by default. This behavior contradicts the official documentation, which states that it should be YES by default. Could someone clarify if this is expected behavior in newer versions of iOS or if there is a known issue regarding this? Any help or clarification would be greatly appreciated! Thanks in advance!
1
0
284
Nov ’24
Live Acitivities - ProgressView problem
Hello i ve implemented progressview and updating the state via push notification. the progress view wants closedrange which i followed but whenever i get update, the progress value resets to beginning my range is like : Date.now..endDate but i dont get it, lets assume that i get the date from database and initialized already then how the code will understand that what progress value will be as current ? it has to be something like i suppose : startDate..Date.now..endDate thanks
0
0
304
Nov ’24