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

Disable iOS 26 UINavigationBar Auto Intvert Background and Title
I have a UISplitView with a UINavigationBar where I on iPhone have an issue with a containing UITableView which is not directly placed under the NavigationBar. When the new effect in iOS 26 kicks in it also seems to affect to topmost UINavigationBar which I do not want. It's when the clear UINavigationBar directly over the UITableView and passes over a content that it needs to invert its title over, it does. However it also inverts everything (background + title) of another topmost uinavigationbar which I don't want. This is even opaque and have no reason to invert its colors. Any ideas on how to disable this? navigationItem.style = .editor navigationItem.centerItemGroups = [editorNavigationHelper.iPadCenterItemGroup()] navigationItem.rightBarButtonItems = editorNavigationHelper.rightBarButtonItems() let documentProperties = UIDocumentProperties(url: document.fileURL) if let itemProvider = NSItemProvider(contentsOf: document.fileURL) { documentProperties.dragItemsProvider = { _ in [UIDragItem(itemProvider: itemProvider)] } documentProperties.activityViewControllerProvider = { UIActivityViewController(activityItems: [itemProvider], applicationActivities: nil) } } navigationItem.title = if UIDevice.current.isIPhone { document.localizedName.trimmedToMax(12, appendingDots: true, adjustForDots: true) } else { document.localizedName } navigationItem.documentProperties = documentProperties navigationItem.titleMenuProvider = { [weak self] suggested in guard let self else { return UIMenu(children: []) } let custom = [ // ... ] return UIMenu(children: suggested + custom) } let navAppearance = UINavigationBarAppearance() navAppearance.configureWithOpaqueBackground() navAppearance.backgroundColor = UIColor.systemBackground navAppearance.titleTextAttributes = [.foregroundColor: UIColor.label] if let navBar = navigationController?.navigationBar { navBar.standardAppearance = navAppearance navBar.scrollEdgeAppearance = navAppearance navBar.compactAppearance = navAppearance navBar.isTranslucent = false navBar.backgroundColor = .systemBackground }
Topic: UI Frameworks SubTopic: UIKit
1
0
43
2h
Abnormal problem when sliding tableview cell
I created a tableview with two cells and configured a left-swipe action for each cell. When I swipe left, the cell displays normally. When I swipe the cell back to its original position, the view displays normally. When I quickly swipe right after the cell has been reset, the view displays noticeably abnormally.
Topic: UI Frameworks SubTopic: UIKit
1
0
14
2h
NSInvalidArgumentException Crash During Keyboard Language Switch on iOS 26
Hello, I have been receiving crash reports on iOS 26 related to a view containing a UITextField. Although I have not been able to reproduce the issue locally and the exact reproduction steps are unknown, the call stack suggests the crash may be related to language or input method changes. If anyone has encountered a similar crash on iOS 26 or has any insights regarding language/input-related issues impacting UITextField behavior, your help would be greatly appreciated. The call stack from the reports is attached below. Exception NSInvalidArgumentException -[__NSPlaceholderArray initWithObjects:count:] attempt to insert nil object from objects[1] Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0xc98c8 __exceptionPreprocess 1 libobjc.A.dylib 0x317c4 objc_exception_throw 2 CoreFoundation 0xe1d7c -[__NSPlaceholderArray initWithObjects:count:] 3 CoreFoundation 0x1485d0 +[NSArray arrayWithObjects:count:] 4 UIKitCore 0xfc4d44 -[UIInlineInputSwitcher updateInputModes:withHUD:] 5 UIKitCore 0xfc4fe0 -[UIIndicatorInputSwitcher switchMode:withHUD:withDelay:] 6 UIKitCore 0xfc31d4 -[UIInputSwitcher showsLanguageIndicator:] 7 UIKitCore 0xa16dc8 __140-[_UIKeyboardStateManager _setupDelegate:delegateSame:hardwareKeyboardStateChanged:endingInputSessionIdentifier:force:delayEndInputSession:]_block_invoke_4 8 libdispatch.dylib 0x1abc _dispatch_call_block_and_release 9 libdispatch.dylib 0x1b7cc _dispatch_client_callout 10 libdispatch.dylib 0x38af0 _dispatch_main_queue_drain.cold.5 11 libdispatch.dylib 0x10ea8 _dispatch_main_queue_drain 12 libdispatch.dylib 0x10de4 _dispatch_main_queue_callback_4CF 13 CoreFoundation 0x6b520 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 14 CoreFoundation 0x1dd14 __CFRunLoopRun 15 CoreFoundation 0x1cc44 _CFRunLoopRunSpecificWithOptions 16 GraphicsServices 0x1498 GSEventRunModal 17 UIKitCore 0xaa6d8 -[UIApplication _run] 18 UIKitCore 0x4ec24 UIApplicationMain Thank you!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
17
6h
preferredTransition not working when using setViewControllers(_:animated:)
I’m using the new preferredTransition = .zoom(...) API introduced in iOS 18. Here’s a simplified version of what I do on app startup: let listVC = CollectionViewController(collectionViewLayout: layout) let detailVC = DetailViewController() detailVC.preferredTransition = .zoom(sourceViewProvider: { context in let indexPath = IndexPath(row: 0, section: 0) let cell = listVC.collectionView.cellForItem(at: indexPath) return cell }) let nav = UINavigationController() nav.setViewControllers([listVC, detailVC], animated: false) window?.rootViewController = nav window?.makeKeyAndVisible() This is meant to restore the UI state from a previous session — the app should launch directly into the DetailViewController. The Problem When I launch the app with setViewControllers([listVC, detailVC], animated: false), the transition from listVC to detailVC appears correctly (i.e., no animation, as intended), but the drag-to-dismiss gesture does not work. The back button appears, and tapping it correctly triggers the zoom-out transition back to the cell, so the preferredTransition = .zoom(...) itself is properly configured. Interestingly, if I delay the push with a DispatchQueue.main.async and instead do: nav.setViewControllers([listVC], animated: false) DispatchQueue.main.async { nav.pushViewController(detailVC, animated: true) } …then everything works perfectly — including the interactive swipe-to-dismiss gesture — but that introduces an unwanted visual artifact: the user briefly sees the listVC, and then it pushes to detailVC, which I’m trying to avoid. My Question Is there a way to enable the swipe-to-dismiss gesture when using setViewControllers([listVC, detailVC], animated: false) It can be very confusing for users if swipe-to-dismiss only works in certain cases inconsistently. Thanks
6
0
250
20h
iPadOS 26 - Status bar overlaps with navigation bar
Hello, I'm experiencing a navigation bar positioning issue with my UIKit iPad app on iPadOS 26 (23A340) using Xcode 26 (17A321). The navigation bar positions under the status bar initially, and after orientation changes to landscape, it positions incorrectly below its expected location. This occurs on both real device (iPad mini A17 Pro) and simulator. My app uses UIKit + Storyboard with a Root Navigation Controller. A stack overflow post has reproduce the bug event if it's not in the same configuration: https://stackoverflow.com/questions/79752945/xcode-26-beta-6-ipados-26-statusbar-overlaps-with-navigationbar-after-presen I have checked all safe areas and tried changing some constraints, but nothing works. Have you encountered this bug before, or do you need additional information to investigate this issue?
1
0
38
23h
iOS 26: UITabBarItem.isEnabled = false no longer prevents selection (works on iOS 18)
Code that disables a tab bar item via UITabBarItem.isEnabled = false used to both grey out the item and block taps on iOS 18. On iOS 26, the item often remains tappable and selectable, even though isEnabled is set to false. This looks like a behavior change or regression. func disableTabbarItems(tabbar: UITabBarController, isEnable: Bool, index: Int) { if let tabItems = tabbar.tabBar.items, index < tabItems.count { let tabItem = tabItems[index] tabItem.isEnabled = isEnable } } iOS 18 iOS 26
1
0
36
1d
iOS 26: UITabBarItem.isEnabled = false no longer prevents selection (works on iOS 18)
Code that disables a tab bar item via UITabBarItem.isEnabled = false used to both grey out the item and block taps on iOS 18. On iOS 26, the item often remains tappable and selectable, even though isEnabled is set to false. This looks like a behavior change or regression. func disableTabbarItems(tabbar: UITabBarController, isEnable: Bool, index: Int) { if let tabItems = tabbar.tabBar.items { let tabItem = tabItems[index] tabItem.isEnabled = isEnable } ![]("https://developer.apple.com/forums/content/attachment/a3c0bafb-2b10-44c3-8d76-d31bd83f30f7" "title=iOS 18.jpg;width=1179;height=279") } ![]("https://developer.apple.com/forums/content/attachment/4bbaccf3-292b-4790-b272-0d9809ba2949" "title=iOS 26.jpg;width=828;height=196")
0
0
4
1d
How to differentiate between user-typed text vs programmatic calls to insertText(_:) in UITextView subclass?
Hi all, I’m subclassing UITextView and overriding insertText(_:) to intercept and log input: class TWTextView: UITextView { override func insertText(_ text: String) { print("insertText() : \(text)") super.insertText(text) } } This works fine, but I’ve noticed that insertText(_:) is invoked both when: The user types something in the text view (via hardware/software keyboard). I programmatically call myTextView.insertText("Hello") from my own code. I’d like to be able to distinguish between these two cases — i.e., know whether the call was triggered by the user or by my own programmatic insert. Is there any recommended way or system-provided signal to differentiate this? Thanks in advance!
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
46
1d
Chaotic keyboard frame notification in windowed app in iOS 26
I have a simple task, to measure the height of the overlapping area occupied by the keyboard in the current view. In the attached images, I use it to position a UITextView (red) above the keyboard, as a test. The keyboard displays an inputAccessoryView (yellow) when editing a text view, but it’s also summoned by a UIFindInteraction, which shows a search bar above the keyboard. When measuring the keyboard, I need to account for either the accessory view or the search bar, basically, the total keyboard height including any extra views above it. I use the usual algorithm: the keyboard frame from UIResponder.keyboardWillShowNotification (documented as being in screen coordinates) is converted to my view’s coordinates and intersected with the view’s bounds to get the overlapping height. The first issue: in windowed mode, the keyboard frame reports a negative origin.x (e.g. -247), even though in screen coordinates it should start at 0. I display the raw frame in the navbar, as shown in the first screenshot. I then suspected the frame might be in window coordinates on iOS 26, but repositioning the window a few times, and switching between find interaction keyboard and text editing keyboard, sometimes yields a positive origin.x instead, as if the keyboard starts from the middle of the screen!? (see the second screenshot). And in some cases, the raw keyboard height is even 0, despite the keyboard clearly being visible and taking space (third screenshot). Interestingly, the reported frame for the search keyboard is always consistent and in screen coordinates, but the default keyboard frame just doesn’t make sense.
0
0
109
1d
UIGlassEffect crashes
Hello there! I’m using UIGlassEffect in my iOS 26 app, which was just approved, but I’m seeing unexpected crashes: +[UIGlassEffect effectWithStyle:]: unrecognized selector sent to class. Could this be happening only for users running earlier betas? Was UIGlassEffect not available in Beta 1–3? I started preparing my update with Beta 4. Thank you!
Topic: UI Frameworks SubTopic: UIKit
1
1
86
2d
iOS 26 UIKIt: Where's the missing cornerConfiguration property of UIViewEffectView?
In WWDC25 video 284: Build a UIKit app with the new design, there is mention of a cornerConfiguration property on UIVisualEffectView. But this properly isn't documented and Xcode 26 isn't aware of any such property. I'm trying to replicate the results of that video in the section titled Custom Elements starting at the 19:15 point. There is a lot of missing details and typos in the code associated with that video. My attempts with UIGlassEffect and UIViewEffectView do not result in any capsule shapes. I just get rectangles with no rounded corners at all. As an experiment, I am trying to recreate the capsule with the layers/location buttons in the iOS 26 version of the Maps app. I put the following code in a view controller's viewDidLoad method let imgCfgLayer = UIImage.SymbolConfiguration(hierarchicalColor: .systemGray) let imgLayer = UIImage(systemName: "square.2.layers.3d.fill", withConfiguration: imgCfgLayer) var cfgLayer = UIButton.Configuration.plain() cfgLayer.image = imgLayer let btnLayer = UIButton(configuration: cfgLayer, primaryAction: UIAction(handler: { _ in print("layer") })) var cfgLoc = UIButton.Configuration.plain() let imgLoc = UIImage(systemName: "location") cfgLoc.image = imgLoc let btnLoc = UIButton(configuration: cfgLoc, primaryAction: UIAction(handler: { _ in print("location") })) let bgEffect = UIGlassEffect() bgEffect.isInteractive = true let bg = UIVisualEffectView(effect: bgEffect) bg.contentView.addSubview(btnLayer) bg.contentView.addSubview(btnLoc) view.addSubview(bg) btnLayer.translatesAutoresizingMaskIntoConstraints = false btnLoc.translatesAutoresizingMaskIntoConstraints = false bg.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ btnLayer.leadingAnchor.constraint(equalTo: bg.contentView.leadingAnchor), btnLayer.trailingAnchor.constraint(equalTo: bg.contentView.trailingAnchor), btnLayer.topAnchor.constraint(equalTo: bg.contentView.topAnchor), btnLoc.centerXAnchor.constraint(equalTo: bg.contentView.centerXAnchor), btnLoc.topAnchor.constraint(equalTo: btnLayer.bottomAnchor, constant: 15), btnLoc.bottomAnchor.constraint(equalTo: bg.contentView.bottomAnchor), bg.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor), bg.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 40), ]) The result is pretty close other than the complete lack of capsule shape. What changes would be needed to get the capsule shape? Is this even the proper approach?
12
5
605
3d
UI resizing / realigning issue in iOS 26 device building in xcode 26
In our app we launch landscape only player view controller from portrait only view controller. This is done using present(playerViewController, animated:true) and it is dismissed using dismiss() api. This is working fine till iOS 18 but broken in iOS 26. Now when presenting the presented viewcontrollers UI is realigning / resizing after the view is visible and while dismissing the presenting view controller is realigning after the view is visible. Anyone else seeing it or how to fix this?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
70
4d
PaperMarkupViewController doesn't conform to MarkupEditViewController.Delegate
In the Meet PaperKit WWDC session in provided sample code, there's: let markupEditViewController = MarkupEditViewController(supportedFeatureSet: .latest) markupEditViewController.delegate = paperViewController However PaperMarkupViewController doesn't conform to MarkupEditViewController.Delegate, it only conforms to MarkupToolbarViewController.Delegate. But based on the demo, MarkupEditViewController is for iOS and MarkupToolbarViewController is for macOS. Compiler gives me the following error: Cannot assign value of type 'PaperMarkupViewController?' to type '(any MarkupEditViewController.Delegate)?' Arguments to generic parameter 'Wrapped' ('PaperMarkupViewController' and 'any MarkupEditViewController.Delegate') are expected to be equal What's the solution here?
Topic: UI Frameworks SubTopic: UIKit
2
0
62
4d
iOS 26 Beta 9 dark/light behaviour over custom UIViews in UITabBarController and CPMapTemplate
I have an app where the user can choose if the dark / light mode is enabled automatically during the night / day (dusk and dawn times are calculated according to to the date and location of the user). I also have an UITabBarController, with two tabs which have a GMSMapView (Google Map View from their SDK), and three tabs with UITableViews. I have noticed that when the automatic change of dark / light mode is performed from dark to light mode, and the user is in a tab with GMSMapView, the tabBar does not change to light model, it remains in dark mode. I perform the switch by setting the self.window.overrideUserInterfaceStyle of the UIWindow of the UIScene. All the views change to light mode, including the navigation bar, but not the tab bar. If I move between the tabs with GMSMapView, the tabBar stays in dark mode. As soon as I move to a tab which contains a UITableView, the tabBar switches to light mode. If the switch to light mode is performed while the user is in tab with the UITableViews, the tabBar switches to light mode immediately, as expected. When moving to the tabs with the GMSMapViews, the tabBar stays in light mode, also as expected. I have also noticed the same problem in CarPlay, in CPMapTemplate (with a UIViewController whose view is GMSMapView), in the buttons with are set with the property “mapButtons”, and with the panning buttons. When the switch from dark mode to light mode is performed by setting the self.window.overrideUserInterfaceStyle of the UIWindow of CarPlay scene, the mapButtons keeps the glyphs in white, and set the background of the buttons to almost white, so the glyphs are barely visible unless you put png images on them instead of SF Symbols. With the panning buttons there is not workaround, since you cannot set custom images for the panning buttons. This happens even if the panning buttons are not being displayed when the switch is performed to light mode, and you enable them later. Is this a bug? Why does this only happen with view over GMSMapView (Google Maps view for a map from their SDK)? Can you think of any viable workaround? Thank you.
3
0
219
4d
iOS 26 applying blur to UIView in navigationBar
Using a storyboard, I created a UIView containing an UIImageView and a UILabel, that I dragged into the navigation bar of one of my viewControllers. In my viewDidLoad I transform the view to move it down past the bounds of the navigation bar so its hidden initially navBarMiddleView.transform = .init(translationX: 0, y: 50) Then as the screen scrolls, I slowly move it up so it slides back into the middle of the navigationBar func scrollViewDidScroll(_ scrollView: UIScrollView) { let padding: CGFloat = 70 let adjustedOffset = (scrollView.contentOffset.y - padding) navBarMiddleView.transform = .init(translationX: 0, y: max(0, (50 - adjustedOffset))) } (The content is displayed in a collectionView cell as large content initially, and I want it to remain visible as the user scrolls down. So a mini view of the same data is moved up into the navigationBar) With iOS 26 the navigationBar is applying a blur effect to this view, even when its outside the bounds of the navigationBar, meaning the content its hovering on top of is slightly obscured. I don't know why this blur is being added, how do I remove it? I've tried the following based on recommendations from chatGPT but none have worked self.navigationController?.navigationBar.clipsToBounds = true self.navBarMiddleView.layer.allowsGroupOpacity = false self.navBarMiddleView.backgroundColor = .clear self.navBarMiddleView.isOpaque = true self.navBarMiddleView.layer.isOpaque = true I have my navigation bar setup with this appearence already: let navigationBarAppearance = UINavigationBarAppearance() navigationBarAppearance.configureWithOpaqueBackground() navigationBarAppearance.backgroundEffect = nil navigationBarAppearance.backgroundColor = UIColor.clear navigationBarAppearance.shadowColor = .clear navigationBarAppearance.titleTextAttributes = [ NSAttributedString.Key.foregroundColor: UIColor.colorNamed("Txt2"), NSAttributedString.Key.font: UIFont.custom(ofType: .bold, andSize: 20) ] UINavigationBar.appearance().standardAppearance = navigationBarAppearance UINavigationBar.appearance().compactAppearance = navigationBarAppearance UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance
2
0
97
5d
How to turn off background extension effect in UISplitViewController?
I have a triple-column UISplitViewController setup in "tile" mode. Each of the 3 columns has a table view controller. Under iPadOS 26, the section headers and row selection in the middle table extends all the way to the left of the screen, behind the primary column. It looks terrible. The documentation for "Adopting Liquid Glass" makes it sound like you can add this behavior by using UIBackgroundExtensionView. But I get this behavior automatically in a UISplitViewController. How do I turn this off? I created a simpler sample using a double-column split view with two table view controllers. Here's a screenshot of the result: Note how the section headers and the row selection appear all the way to the left edge of the screen. I don't want that effect. How do you turn off this effect in a UISplitViewController? Here is the code used to setup the split view and the app's main window: func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let winScene = (scene as? UIWindowScene) else { return } let primary = PrimaryViewController(style: .plain) let primaryNC = UINavigationController(rootViewController: primary) let detail = DetailViewController(style: .plain) let detailNC = UINavigationController(rootViewController: detail) let sv = UISplitViewController(style: .doubleColumn) sv.preferredDisplayMode = .oneBesideSecondary sv.preferredSplitBehavior = .tile sv.primaryBackgroundStyle = .none sv.displayModeButtonVisibility = .automatic sv.setViewController(primaryNC, for: .primary) sv.setViewController(detailNC, for: .secondary) let win = UIWindow(windowScene: winScene) win.rootViewController = sv win.makeKeyAndVisible() window = win } The PrimaryViewController and DetailViewController are simple UITableViewController subclasses that only add a few rows and section headers as needed.
0
0
46
5d
NSToolbar Space item rendered with Liquid Glass Background
Hi, I have a NSToolbar in my Mac Catalyst app with a space and flexible space item in it (https://developer.apple.com/documentation/appkit/nstoolbaritem/identifier/space). On macOS Tahoe the space item is being rendered with a Liquid Glass effect and seems to be automatically grouped with the previous item. Is there a way to prevent this? It basically adds some undesired padding next to the previous item and looks add. The flexible space is rendered normally and as before. I am talking about the space right next to the back chevron item. Thanks for any hints!
1
0
84
5d
Simulating key press event to type text in UITextField
in iOS, user can set focus on UItextField and tapping a key in the virtual keyboard updates the text in the textfield. This user action causes the relevant delegates of UITextFieldDelegate to get invoked, i.e the handlers associated with action of user entering some text in the textfield. I m trying to simulate this user action where I am trying to do this programatically. I want to simulate it in a way such that all the handlers/listeners which otherwise would have been invoked as a result of user typing in the textfield should also get invoked now when i am trying to do it programatically. I have a specific usecase of this in my application. Below is how I m performing this simulation. I m manually updating the text field associated(UITextField.text) and updating its value. And then I m invoking the delegate manually as textField.delegate?.textField?(textField, shouldChangeCharactersIn: nsRange, replacementString: replacementString) I wanted to know If this is the right way to do this. Is there something better available that can be used, such that simulation has the same affect as the user performing the update?
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
306
5d