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

UIKit Documentation

Posts under UIKit subtopic

Post

Replies

Boosts

Views

Activity

UICollectionView cells don't show accessibility numbers or labels
I started to use the Accessibility features of UIKit but cannot get the numbers or labels to show up on UICollectionCells. The image here shows a 3x3 matrix with no numbers, but the numbers on the menu commands show up. Actually these are just iOS accessibility features, not my app. I've tried reducing the size of my images or no images, but nothing shows up (in any of my UICollection code). I can get them to work on UITableView cells. I've tried the Accessibility selection in the storyboard or code, but nothing helps.
0
0
106
3d
VisionKit adds unexpected extra space above “Retake / Keep” controls after scanning
We are facing a UI layout issue while using VisionKit (VNDocumentCameraViewController) for document scanning. After capturing a document, an unexpected extra blank space appears above the “Retake” and “Keep” action bar also in Bottom. This extra space is not part of our custom UI and seems to be introduced by VisionKit itself. This issue impacts the final scan preview layout and reduces usable screen space, especially noticeable on devices all the device iPhone or iPad
0
0
21
1w
DeclaredAgeRange.requestAgeRange returns .notAvailable despite Family‑Sharing child account (iOS 26.2, Xcode 26.2)
Hello — I’m integrating DeclaredAgeRange to check >=18 at app registration, but the API keeps returning AgeRangeService.Error.notAvailable. I’ve tried family sharing and sandbox age settings without success. Below is a minimal environment, the exact code I call, my concise questions, and the expected behaviour. I can attach Console logs and screenshots if helpful. Environment Xcode: 26.2 Device OS: iOS 26.2 on real device Capabilities: Declared Age Range capability enabled in Xcode entitlements Framework integration: DeclaredAgeRange framework imported/linked in the project App compiled and installed from Xcode using development provisioning profile Device main Apple ID: I attempted both (a) Family‑Sharing child account logged in as device main Apple ID and (b) sandbox App Store account age settings via Settings → App Store → Sandbox Account → Manage → Age Verification Minimal code I if #available(iOS 26.2, *) { #if canImport(DeclaredAgeRange) do { let response = try await AgeRangeService.shared.requestAgeRange(ageGates: 18, in: self) switch response { case let .sharing(range): // handle range case .declinedSharing: // handle declined @unknown default: // handle unknown } } catch let err as AgeRangeService.Error { if case .notAvailable = err { print("AgeRange notAvailable") } else { print("AgeRange other error: \(err)") } } catch { print("AgeRange generic error: \(error)") } #endif } Key questions (please answer briefly) Must the device main Apple ID be a Family‑Sharing child account (created/managed by a parent) for DeclaredAgeRange to ever return .sharing? Or can the App Store “Sandbox Account → Age Verification” produce a shareable result for this API? If the device main Apple ID must be a family child account, is there any Apple-side flag/setting (server-side) that Apple support must enable for that Apple ID to be eligible for age sharing? Does App Store Connect / app metadata / age rating or entitlements require any special setting for DeclaredAgeRange to work in the sandbox/dev environment? Are there known region/locale constraints (e.g., device region must be US) that commonly cause .notAvailable? What Console/system logs should I capture and attach to help determine whether the request reaches Apple backend vs. is blocked locally? (exact log names/filters welcome) Is there a canonical sandbox test flow doc for family/parent flows DeclaredAgeRange that guarantees a working test sequence?
Topic: UI Frameworks SubTopic: UIKit
2
0
163
6d
Where to find sample code for SB2420 compliance and questions
I'm struggling to implement required code for SB2420 compliance. I try to learn on a very simple use case. the app is UIKit Build in Xcode 26.2 it displays a single Hello view with a button that will simply show a "Good day" label. I assume the app will be rated 4+. I tried the following code, using available information in Xcode (limited): import UIKit import DeclaredAgeRange // other import needed ? class ViewController: UIViewController { @IBOutlet weak var welcomeLabel: UILabel! // initially hidden override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } func testAgeRange() -> Bool { if !isEligibleForAgeFeatures { // Not found. Which import needed ? return true // Not called from Texas } // Following code from Xcode doc… do { let response = try await AgeRangeService.shared.requestAgeRange(ageGates: 13, 15, 18) // Compiler Error: Missing argument for parameter 'in' in call // Can I add the 4 gate ? guard let lowerBound = response.lowerBound else { // Allow access to under 13 features. return false } var ok = false if lowerBound >= 18 { // Not needed ? // Allow access to 18+ features. ok = true } else if lowerBound >= 15 { // Not needed ? // Allow access to 15+ features. ok = true } else if lowerBound >= 13 { // Not needed ? // Require parental consent ? // Allow access to 13+ features. ok = true // if consent OK } else { // Require parental consent ? // Show age-appropriate content ok = true // if consent OK } return ok // Authorized for all 4+ } catch AgeRangeService.Error.notAvailable { // No age range provided. return false } } func executeStart() { welcomeLabel.isHidden = false } @IBAction func start(_ sender: UIButton) { if #available(iOS 26.0, *) { if testAgeRange() { // Need to test for parental control here ? } else { // Alert and exit the app ? } } else { // do nothing ? Can we run the app ? } executeStart() } } The logic would be: before allowing action with the start button, check is it IOS 26+ so that we can call API if so, is verification needed (Texas SB2420) if not, we can proceed if required, test age range As app is 4+, all ranges should be OK But need to test parental control Now, many pending questions in code: line 14: get an error: Cannot find 'isEligibleForAgeFeatures' in scope line 19: I used the documentation sample for AgeRangeService, but get a Compiler Error: Missing argument for parameter 'in' in call line 35: how to implement parental control ? In addition, in the metadata of the app, should I declare that parental control ? Age verification? Mechanism for confirming that a person's age meets the age requirement for accessing content or services As there is no restriction on age, is it required ? Any help welcomed as well as link to a comprehensive tutorial.
2
0
209
1w
The latest iPhone model cannot retrieve the Wi-Fi information it has connected to.
The latest iPhone model is unable to retrieve the Wi-Fi information it has connected to. The phone's operating system is iOS 26.1, and location permission has also been granted. "Access Wi-Fi Information" is also configured in the same way The following is the code I used to obtain Wi-Fi information: func getCurrentWiFiInfo() -> String? { guard let interfaces = CNCopySupportedInterfaces() as? [String] else { return nil } for interface in interfaces { guard let info = CNCopyCurrentNetworkInfo(interface as CFString) as? [String: Any] else { continue } if let ssid = info[kCNNetworkInfoKeySSID as String] as? String, !ssid.isEmpty { return ssid } } return nil }
0
0
106
1w
UIBarButtonItem has a lot of constraints warnings
The issue can be reproduced using the simplest code. In Xcode 26 + iOS 26, when a UIBarButtonItem is created using a UIImage, it consistently prints numerous constraint conflict warnings to the console. Below is my test code and the console warnings: let btn = UIBarButtonItem(systemItem: .trash) self.toolbarItems = [btn] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x1083b4550 _TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x108374e00.width == _UIButtonBarButton:0x1083e8000.width (active)>", "<NSLayoutConstraint:0x1083b4aa0 'IB_Leading_Leading' H:|-(2)-[_UIModernBarButton:0x103ac62e0] (active, names: '|':_UIButtonBarButton:0x1083e8000 )>", "<NSLayoutConstraint:0x1083b4af0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x103ac62e0]-(2)-| (active, names: '|':_UIButtonBarButton:0x1083e8000 )>", "<NSLayoutConstraint:0x1083b4fa0 'UIView-Encapsulated-Layout-Width' _TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x108374e00.width == 0 (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x1083b4af0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x103ac62e0]-(2)-| (active, names: '|':_UIButtonBarButton:0x1083e8000 )> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
3
0
212
1w
UIToolbar buttons losing spacing in Xcode 26.1.1 Legacy Mode (UIDesignRequiresCompatibility)
We're using XCode 26.1.1 We do not have resource to adopt Liquid Glass design. Hence, we are using the following workaround <key>UIDesignRequiresCompatibility</key> <true/> This is our Storyboard. Pre XCode 26 Before XCode 26.1.1, the bottom toolbar looks great. In XCode 26 However, in XCode 26.1.1, the bottom toolbar buttons seems to "Squish together". Do anyone have any idea, how I can make UIToolbar works by enabling UIDesignRequiresCompatibility? Thanks.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
92
2w
Persistent Control Center landscape layout reset after SpringBoard jetsam during charging idle (iOS 26.0–26.2)
Since iOS 26.0, the Control Center layout consistently resets in landscape orientation after certain system events. This issue is still present in the official public release of iOS 26.2. The reset occurs without a visible reboot and appears to be triggered by a background SpringBoard termination (jetsam) during charging idle maintenance windows (typically overnight while the device is plugged in). After SpringBoard relaunches: • The portrait Control Center layout is restored correctly • The landscape Control Center layout is reinitialized using the default order This indicates a state restoration failure rather than a user configuration or sync issue. ⸻ Steps to Reproduce: Use an iPhone 15 Pro running iOS 26.0, 26.1, or 26.2 Manually reorder Control Center controls Leave the device plugged in and idle overnight During charging idle, SpringBoard is terminated in the background due to memory pressure (no visible reboot) Open Control Center the next day: • Portrait layout is preserved • Landscape layout has reverted to default ⸻ Expected Result: Both portrait and landscape Control Center layouts should persist across SpringBoard restarts caused by jetsam or memory pressure, including during charging idle maintenance. ⸻ Actual Result: After SpringBoard relaunch: • Portrait layout is restored correctly • Landscape layout is lost and recreated using the default configuration ⸻ Analytics / Logs (relevant excerpt): Process: SpringBoard Case Type: MemoryResourceException Subtype: MREExceptionFatalLimitActive This occurs during charging idle and does not require a user-initiated reboot. ⸻ Additional Observations: • Issue does not occur when the device is idle overnight without charging • Manual reordering works correctly until the next SpringBoard jetsam • Resetting settings, disabling iCloud sync, or reinstalling iOS does not resolve the issue • This behavior has persisted across multiple major and minor releases, indicating a regression or unresolved bug ⸻ Suspected Root Cause: Incomplete state restoration in ControlCenterKit after SpringBoard relaunch following jetsam during charging idle. Portrait state is restored; landscape state falls back to default.
Topic: UI Frameworks SubTopic: UIKit
1
0
106
1w
How to prevent window scene restoration
We have an iOS app running on macOS (not Mac Catalyst). The preferences are in a dedicated UIWindowScene. We don't want this scene to be restored, so when you start the app the preferences shouldn't be visible. How can we prevent the UIWindowScene restoration? Alternatively, if we can't prevent it, how can we ensure the main window scene is in front of the preferences window scene on app start?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
43
2w
iOS 26 WKWebView STScreenTimeConfigurationObserver KVO Crash
Fatal Exception: NSInternalInconsistencyException Cannot remove an observer <WKWebView 0x135137800> for the key path "configuration.enforcesChildRestrictions" from <STScreenTimeConfigurationObserver 0x13c6d7460>, most likely because the value for the key "configuration" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the STScreenTimeConfigurationObserver [class.] I noticed that on iOS 26, WKWebView registers STScreenTimeConfigurationObserver, Is this an iOS 26 system issue? What should I do?
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
233
6d
UIBarButtonItem and Liquid Glass
I am looking for a way to change the liquid glass background colors on UIBarButtonItems. Setting tintColor does what I want for a bar button item when it is both the default button and it is enabled. But it does not seem to do anything for disabled buttons or non-prominent buttons. Also, is there a way to apply such a change using a UINavigationBarAppearance or a UIBarButtonItemAppearance? If I cannot change this liquid glass color, I might need to disable liquid glass on these by setting hidesSharedBackground to true. Is there a way to do this globally within the app (without using UIDesignRequiresCompatibility), or with something like UINavigationBarAppearance or UIBarButtonItemAppearance? Thank you. John
Topic: UI Frameworks SubTopic: UIKit
2
0
175
2w
Share Sheet with UIActivityItemsConfiguration
I am trying to address an issue with my app’s share sheet where, when the user sends a URL to either Apple Reminders or OmniFocus, the receiving app does not get a title. So I am updating my share sheet code to use UIActivityItemsConfiguration. I have this code: let title = "Golden Hill Software" let url = URL(string: "https://www.goldenhillsoftware.com/")! let itemProvider = NSItemProvider() itemProvider.registerObject(ofClass: URL.self, visibility: .all) { (handler) in handler(url, nil) return nil } let config = UIActivityItemsConfiguration(itemProviders: [itemProvider]) config.metadataProvider = { (key) in if key == .title || key == .messageBody { return title } else { return nil } } let viewController = UIActivityViewController(activityItemsConfiguration: config) self.present(viewController, animated: true) This works with some share sheet extensions. But when I choose the Ivory share extension, Ivory creates a post with a URL that starts with bplist…. When I choose the Open in Chrome action extension, Chrome says “Chrome cannot handle this link”. Can someone help me understand what I am doing wrong here? (edited)
Topic: UI Frameworks SubTopic: UIKit
0
0
42
2w
UIKit - Stop ongoing animation on the extended setVisibleMapRect Animation time on MapKit
Hi team, I've been trying to extend the animation when we call the function setVisibleMapRect, we can use UIView.animate to lengthen the animation time, but one thing that I found not working is that when I extend the animation to 3, 5, or 10 seconds, and the changes is still ongoing and there's a gesture performed, the map will completely ignore the gesture. Causing the map to be having this kind of like "delayed" or "freeze" experience for the user. The map will immediately move to the final rect and ignores the user gesture. I've been checking on this problem for a week now and I'm quite stuck. I've tried using CADisplayLink to manually animate the camera per system fresh rate, it works very well, I can stop the camera movement anytime there are touches, but it causes the resource CPU spikes. Removing the animation layers recursively on sublayers and subviews also doesn't help. While storing the animation into a UIViewPropertyAnimator and use stopAnimation will always ignores user first interactions too while also animating the camera to the final position (which is not expected).
3
0
180
1w
How to move focus across multiple textfields using arrow keys/enter key in iOS
Hi. I have an iOS application with multiple input fields. I have to design an experience such that whenever the user presses enter key on a textfield, it should move focus to the next input field. Similarly, consider a stack of 3 textfields, I want to cycle the focus as and when the user presses up/down arrow keys. Other platforms like Android, have this feature out-of-the-box. I wanted to understand if iOS also supports this kind of behavior. I know how to manually code such UX, but just wanted to confirm whether there is some inherent feature like on android which i can leverage? Thanks.
0
0
46
2w
Flutter iOS - EXC_BAD_ACCESS crash on cold start after app was killed, affects ~1-2% of users
Question: How to prevent Flutter app crash on iOS 18 during cold start when iOS traverses view hierarchy before Flutter engine is fully initialized? Help needed: Looking for a way to either delay iOS view hierarchy traversal or ensure Flutter is fully initialized before iOS lifecycle callbacks fire. Problem Summary Our Flutter app crashes on cold start for approximately 1-2% of iOS users. The crash occurs specifically on iOS and only under these exact conditions: When crash happens: User opens app and uses it normally ✅ User minimizes app (goes to background) ✅ User returns to app from background ✅ (works fine) User kills app from app switcher (swipe up to close) User taps app icon to launch again → CRASH ❌ Key observations: Crash is intermittent - app may open on 2nd, 3rd, or 5th attempt 100% reproducible on affected devices by repeating kill→launch cycle ~98% of users have no issues Environment Flutter: 3.38.3 Crash Logs (from Sentry) Crash Type 1: Stack Overflow (most common) OS Version: iOS 18.7.2 (22H124) Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: BUS_NOOP at 0x000000016ad5be90 Application Specific Information: compare:options:range:locale: > Stack overflow in (null) Thread 0 Crashed: 0 CoreFoundation CFStringGetLength 1 CoreFoundation CFStringCompareWithOptionsAndLocale 2 CoreFoundation 3 libsystem_c bsearch 4 CoreFoundation 5 UIKitCore ... 15-99: UIKitCore 0x30e177148 [inlined] // 85+ recursive calls Crash Type 2: Use-After-Free Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: SEGV_NOOP at 0x0500007f14000000 KERN_INVALID_ADDRESS at 0x500007f14000000 Thread 0 Crashed: 0 libobjc.A.dylib objc_retainAutoreleaseReturnValue 1 UIKitCore ... 6 libobjc.A.dylib objcrootDealloc 7 QuartzCore // CALayer operations What We Tried (nothing solved cold start crash) Attempt Result Increased stack size to 64MB (-Wl,-stack_size,0x4000000) ❌ No effect Disabled iOS State Restoration ❌ No effect Added isViewLoaded checks in AppDelegate ❌ No effect Added try-catch around GetStorage/SecureStorage init ❌ No effect Added isAppActive flag to track app state ❌ No effect Snapshot overlay in applicationWillResignActive ✅ Fixed background→foreground crash, ❌ but NOT cold start Current AppDelegate.swift import UIKit import Flutter @main @objc class AppDelegate: FlutterAppDelegate { private var snapshotView: UIView? private var isAppActive = false override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) window?.overrideUserInterfaceStyle = .light isAppActive = true return super.application(application, didFinishLaunchingWithOptions: launchOptions) } override func application(_ application: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> Bool { return false } override func application(_ application: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool { return false } override func applicationWillResignActive(_ application: UIApplication) { guard isAppActive, let window = self.window, let rootVC = window.rootViewController, rootVC.isViewLoaded, snapshotView == nil else { return } let snapshot = UIView(frame: window.bounds) snapshot.backgroundColor = .white snapshot.tag = 999 window.addSubview(snapshot) snapshotView = snapshot } override func applicationDidBecomeActive(_ application: UIApplication) { guard snapshotView != nil else { isAppActive = true return } snapshotView?.removeFromSuperview() snapshotView = nil } }
Topic: UI Frameworks SubTopic: UIKit
1
0
109
2w
Flutter iOS crash on cold start - EXC_BAD_ACCESS Stack overflow in UIKit view hierarchy
I'm experiencing intermittent crashes on iOS when launching a Flutter app after it was killed from the app switcher. The app works fine when resumed from background. Environment: Flutter 3.38.3 Crash signature: EXC_BAD_ACCESS (SIGBUS) Stack overflow in (null) compare:options:range:locale: > Thread 0: CFStringGetLength → CFStringCompareWithOptionsAndLocale → UIKitCore ( 85+ inlined recursive calls) What I've tried: Increased stack size to 64MB (-Wl,-stack_size,0x4000000) - didn't help Disabled iOS State Restoration - didn't help Added snapshot overlay in applicationWillResignActive - helped for background issue, but not cold start Key observation: The crash happens intermittently. Sometimes the app opens on 2nd attempt, sometimes on 5th. This suggests a race condition between Flutter engine initialization and iOS view hierarchy traversal. Question: Is there a way to delay iOS view hierarchy operations until Flutter is fully initialized? Any help appreciated!
Topic: UI Frameworks SubTopic: UIKit
1
0
99
2w
[Xcode 26.2] Weird animation of first-level view controller being pushed on iOS 26 (with hidesBottomBarWhenPushed)
Hi. We discovered this strange behaviour when we're planning to migrate to Xcode 26.2 RC. When our app is running on iOS 26, view controllers thar are pushed from the root of UITabBarController will show with an animation. The views are growing from either the top-left or bottom-right corner. This only happens when the hidesBottomBarWhenPushed variable is set to true. Also it only happens to view controllers that are pushed directly from a UITabBarController; subsequent view controllers that are pushed will not have this weird animation. Since our app design requires hidesBottomBarWhenPushed to be true, we are asking if there is any way to fix this animation. Please refer to the following gif: We have tried methods described in this article but it doesn't work all the time: https://darjeelingsteve.com/articles/Fixing-UINavigationController-Push-Animation-Layout-Issues-on-iOS-26.html. We've tried the following three methods: This does not work at all. First-level view controllers are still showing with animation. override func pushViewController(_ viewController: UIViewController, animated: Bool) { super.pushViewController(viewController, animated: animated) transitionCoordinator?.animate { _ in UIView.performWithoutAnimation { viewController.view.layoutIfNeeded() } } } This does not work as well. override func pushViewController(_ viewController: UIViewController, animated: Bool) { super.pushViewController(viewController, animated: animated) transitionCoordinator?.animate(alongsideTransition: { [weak self] _ in UIView.performWithoutAnimation { self?.navigationBar.layoutIfNeeded() } }, completion: nil) } This works sometimes. However it breaks the push animation for some view controllers. override func pushViewController(_ viewController: UIViewController, animated: Bool) { super.pushViewController(viewController, animated: animated) UIView.performWithoutAnimation { viewController.view.layoutIfNeeded() } } We've created a simple sample project that reproduces this problem. Please run it on a simulator running iOS 26. https://drive.google.com/file/d/1q3pokphh1YDINH69LrHuqJQe8MijHQ2m/view?usp=sharing If anyone has a solution to this please let me know. Thank you for reading.
Topic: UI Frameworks SubTopic: UIKit
0
1
101
2w