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

UIScene based state restoration on tvOS not working
I can’t get UIScene-based state restoration to work on tvOS as it does on iOS. UISceneSession.stateRestorationActivity is always nil in UIWindowSceneDelegate.scene(_:willConnectTo:options:) despite UIWindowSceneDelegate.stateRestorationActivity(for:) being called in the previous lifecycle. The NSUserActivityType is correctly configured in the Info.plist. Has anyone encountered the same issue or knows how to get this to work? Sample Project https://github.com/antiraum/tvosSceneStateRestoration Feedback FB20451479
1
0
54
2w
Using UIDocumentViewController with UISplitViewController in Xcode 26
I created a UIKit Document-Based App in Xcode 26. When using UIDocumentViewController on its own, everything works fine. However, when I try to use it with UISplitViewController or add a Toolbar, I run into an issue: the Sidebar and Toolbar UI remain visible above the Document Browser. Older sample projects show a Document-Based App set up with UISplitViewController, but it seems like with the more recent recommended approach, UISplitViewController may no longer be supported. Is that correct? While I could give up on using a Toolbar, I’d really like to know if there’s still a way to use UISplitViewController together with UIDocumentViewController.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
30
2w
Image sizing in context menus on Tahoe via Catalyst
I've got a Catalyst app that exposes some custom context menu items via the buildMenu API. When it runs on Tahoe, there's some weirdness with how the images in the menu items are sized. See attached screenshot below. The three items on the bottom are using SF Symbols for their images, and the rest are using custom images from an asset catalog. Is this a bug in Tahoe 26.0? Or should I be resizing my images before giving them to UIAction? If the latter, what should the size be, and is this documented somewhere or available from an API?
0
2
79
2w
UIModernBarButton causing a lot of console constraint warning and eventual animation glitches
is there anything I can do about this? It's in a navigation controller, and I get a lot of these when I pop and push. eventually it causes glitches with zoom animations making for some really loopy zooms. I posted a movie to FB20439774. If there's anything I can do to fix it would be great. Unable to simultaneously satisfy constraints. ( "<NSAutoresizingMaskLayoutConstraint:0x600002149680 h=-&- v=-&- TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x106b0e700.minX == 0 (active, names: '|':TtGC5UIKit22UICorePlatformViewHostGVS_32PlatformViewRepresentableAdaptorVS_P10$186c5d1b020ButtonRepresentation:0x106b08ef0 )>", "<NSAutoresizingMaskLayoutConstraint:0x600002149590 h=-&- v=-&- H:[TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x106b0e700]-(0)-| (active, names: '|':TtGC5UIKit22UICorePlatformViewHostGVS_32PlatformViewRepresentableAdaptorVS_P10$186c5d1b020ButtonRepresentation:0x106b08ef0 )>", "<NSLayoutConstraint:0x600002142b20 _TtC5UIKitP33_DDE14AA6B49FCAFC5A54255A118E1D8713ButtonWrapper:0x106b0e700.width == _UIButtonBarButton:0x106b16ef0.width (active)>", "<NSLayoutConstraint:0x60000214a4e0 'UITemporaryLayoutWidth' TtGC5UIKit22UICorePlatformViewHostGVS_32PlatformViewRepresentableAdaptorVS_P10$186c5d1b020ButtonRepresentation:0x106b08ef0.width == 0 (active)>", "<NSLayoutConstraint:0x600002143200 'IB_Leading_Leading' H:|-(1)-[_UIModernBarButton:0x106b09810] (active, names: '|':_UIButtonBarButton:0x106b16ef0 )>", "<NSLayoutConstraint:0x6000021434d0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106b09810]-(1)-| (active, names: '|':_UIButtonBarButton:0x106b16ef0 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000021434d0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x106b09810]-(1)-| (active, names: '|':_UIButtonBarButton:0x106b16ef0 )>
1
1
82
2w
UIStepper can't reach min/max value
When I build my project with Xcode 26 the following code makes the stepper decrement option disabled: stepper.stepValue = 0.5 stepper.value = 1.0 stepper.minimumValue = 0.7 stepper.maximumValue = 4.0 I think the reason for this is that the (value - stepValue) goes bellow the minimumValue. But on all iOS versions before iOS 26 this made the decrement option enabled and it clamped the value to the minimumValue. The same issue can be reproduced for the maximumValue. Does anyone else have the same issue? Do we need to adjust the stepValue based on the current value?
1
0
67
2w
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?
6
1
289
2w
hidesBottomBarWhenPushed is bugged on iOS 26
I am using a common UI pattern: UITabBarController as window root, each tab with a separate UINavigationController stack. I want the (bottom!) tab bar to be only visible when the user is at the root of the app and hide it when a detail page is opened. To do that, I used hidesBottomBarWhenPushed on any view controller that would be pushed on my navigation stacks and that worked fine in the past. But with iOS 26, I am seeing several issues: On iOS where when the bottom tab bar is used, when in a details page and navigating back, the tab bar becomes fully visible immediately instead of slowly animating in as it has been in the past. This is particular visible and annoying when using the "swipe to go back" gesture On iPad, the situation is even worse: On iPadOS 18, the tab bar appeared in the navigation controller's navigation bar - no matter if hidesBottomBarWhenPushed was set or not - fine. But now, with iPadOS 26, this top tab bar disappears when a child is pushed. Not only that, it disappears abruptly, without animation, and the Liquid Glass effect on the UIBarButtonItems is broken as well. There is no transition whatsoever, buttons are simply replaced with the new UIBarButtonItems of the pushed view controller once it became fully visible. It gets even worse when swipe-back navigating on iPadOS: As soon as the back transition starts, the tab bar becomes visible again (without animation), covering the title (view) of the UINavigationController. If the swipe-back transition is not completed the tab bar suddenly stays visible When the swipe-back transition is interrupted close to the end of the transition and it goes back to the pushed view controller, the top UIBarButtonItems are showing a visual glitch where the content (text or icon) stays on the area where the tab bar is, while their container (the glass effect) are on the vertically aligned to the title view. I am surprised that I have not found any similar reports of these problems, so I am wondering if I am doing anything wrong or using hidesBottomBarWhenPushed simply isn't recommended or supported any more.
0
0
87
2w
Why the backgroud color changes when I draw on the canvas?
override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .gray view.insetsLayoutMarginsFromSafeArea = false setupCanvasView() setupToolPicker() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) // 确保画布成为第一响应者以显示工具栏 canvasView.becomeFirstResponder() } func setupCanvasView() { canvasView.frame = view.bounds canvasView.delegate = self canvasView.insetsLayoutMarginsFromSafeArea = false // 设置画布属性以支持绘画 canvasView.alwaysBounceVertical = true canvasView.alwaysBounceHorizontal = true canvasView.isScrollEnabled = true canvasView.showsVerticalScrollIndicator = true canvasView.showsHorizontalScrollIndicator = true canvasView.contentSize = CGSize(width: 500,height: 500) // 启用绘画功能 canvasView.drawingPolicy = .anyInput // 支持手指和 Apple Pencil view.addSubview(canvasView) } AS THE CODE ABOVE,WHEN I DRAW ON THE CANVAS,THE BACKGROUND CHANGE ITS COLOR TO WHITE, how to fix it? !
Topic: UI Frameworks SubTopic: UIKit
0
0
28
2w
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.
1
0
251
2w
Forced Orientation + iOS 26?
Hello, I have an app which is a full screen app. Since updating xcode, the force-landscape and force-portrait modes are broken. I am looking for a way to have a full-screen app in landscape, or a full-screen app in portrait. The previous process that I found, which worked was the following: setNeedsUpdateOfSupportedInterfaceOrientations() UIWindowScene.requestGeometryUpdate(.landscape) Then returning the correct value on uiviewcontroller override var supportedInterfaceOrientations : UIInterfaceOrientationMask { return [.portrait, .portraitUpsideDown, .landscapeLeft, .landscapeRight] } This is going to destroy 2 full years of development, the entire app hinges on being able to use portrait OR landscape mode. There are portrait scenes and landscape scenes. When you setup a scene, you can rotate the device. Once the scene is setup, it needs to be fixed into one orientation and run full-screen. Please let me know best practices for this use case. I look to the monks, jedis, ninjas, and warriors to guide me through this swamp of sorrows. Thanks!
Topic: UI Frameworks SubTopic: UIKit
2
0
84
2w
How to enable the "Paste and Match Style" context menu in a UITextView?
The UIResponderStandardEditActions protocol includes pasteAndMatchStyle:. UITextView conforms to UIResponderStandardEditActions. But I can't find a way to get that menu to appear. I get the standard "Paste" menu. I've tried overriding pasteAndMatchStyle: in a subclass of UITextView. I've overridden canPerformAction:withSender: but it never gets called with the pasteAndMatchStyle: selector. I've implemented the textView:editMenuForTextInRange:suggestedActions: delegate method. It's called but the suggested actions do not include the "Paste and Match Style" action (key command). I came up with an ugly hack that involved overriding buildMenuWithBuilder: and adding my own key command after the paste command. But this shouldn't be necessary considering it's supposed to be a standard edit action. So what's the trick to make the "Paste and Match Style" edit menu appear properly in a UITextView? I'm testing with iOS 17, 18, and 26.
2
0
151
2w
WHY THE BACKGROUND CHANGE ITS COLOR AUTOMATIC?
override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .gray view.insetsLayoutMarginsFromSafeArea = false setupCanvasView() setupToolPicker() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) // 确保画布成为第一响应者以显示工具栏 canvasView.becomeFirstResponder() } func setupCanvasView() { canvasView.frame = view.bounds canvasView.delegate = self canvasView.insetsLayoutMarginsFromSafeArea = false // 设置画布属性以支持绘画 canvasView.alwaysBounceVertical = true canvasView.alwaysBounceHorizontal = true canvasView.isScrollEnabled = true canvasView.showsVerticalScrollIndicator = true canvasView.showsHorizontalScrollIndicator = true canvasView.contentSize = CGSize(width: 500,height: 500) // 启用绘画功能 canvasView.drawingPolicy = .anyInput // 支持手指和 Apple Pencil view.addSubview(canvasView) } AS THE CODE ABOVE,WHEN I DRAW ON THE CANVAS,THE BACKGROUND CHANGE ITS COLOR TO WHITE.WHY? !
Topic: UI Frameworks SubTopic: UIKit
0
0
61
2w
View title misaligned after compiling with Xcode 26
After compiling with Xcode 26, my UIKit view's title appears hugging the screen on the left when run on iOS 16-18 (as shown in the image below). It's fine when run on iOS 26, but not older iOS versions. When I compile the same code with Xcode 16.4, the title aligns with the table rows. Has anyone else seen this? Is this a bug in the frameworks or is there something I could do to resolve?
1
0
80
2w
UIRequiresFullScreen alternative for iPadOS 26+
My apps are using UIRequiresFullScreen = YES in the info.plist. Now that this is deprecated for iPadOS 26+, I'm updating my apps and using the UIWindowScene's sizeRestriction property to ensure a certain minimum size of the window. I've enabled all orientations support for iPads in the plist as well as the supportedInterfaceOrientations property of the ViewController. On iPadOS 26, the following line works - windowScene.sizeRestrictrions?.minimumSize = CGSize(480,720) The window does not resize below the above threshold and everything works as expected. However on the iPad simulators for 18.x (with Stage Manager enabled), the above sizeRestrictions property is never set. It shows up as nil even after the views have been laid out. The simulator allows me to drag the window handle and shrink the window to well below the specified threshold, all the way down to a width of 375. Is there anyway I can set the sizeRestrictions for iPadOS 18.x and lower?
1
0
146
3w
Custom Background Image Fails to Display on UIToolbar
I am encountering a critical issue where a custom background image on a UIToolbar fails to display when the app is built with Xcode 26 and run on iOS 26 beta. The exact same implementation works perfectly on iOS 18 and earlier versions. We first attempted to use the legacy setBackgroundImage method, which fails to render the image on iOS 26: // 1. Get Navigation Bar and set basic properties UINavigationBar* navBar = self.navigationBar; navBar.hidden = NO; navBar.translucent = NO; // 2. Setup the UIToolbar instance UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:navBar.bounds]; toolBar.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; // 3. Set the resizable image (This image does not appear on iOS 26) UIImage* imagePortrait = [UIImage imageNamed:@"nav_bg"]; UIEdgeInsets insets = UIEdgeInsetsMake(0.f, 6.f, 0.f, 6.f); [toolBar setBackgroundImage:[imagePortrait resizableImageWithCapInsets:insets] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault]; We then migrated to the recommended modern UIToolbarAppearance to solve this, but the issue persists: // 1. Prepare Image UIImage* imagePortrait = [UIImage imageNamed:@"nav_bg"]; // Insets are applied via resizableImageWithCapInsets: (not shown in this snippet but implied) // 2. Configure UIToolbarAppearance UIToolbarAppearance *appearance = [[UIToolbarAppearance alloc] init]; appearance.backgroundImage = imagePortrait; // The image is correctly loaded (not nil) // 3. Apply the Appearance toolBar.standardAppearance = appearance; // We also applied to scrollEdgeAppearance and compactAppearance. Any information or recommended workarounds for displaying a custom background image on UIToolbar in the latest iOS 26 would be highly appreciated.
0
1
140
3w
UIVisualEffectView and UIBlurEffect under iOS 26
When tapping a UIButton I present a view controller like this: let vc = ViewController() present(vc, animated: true, completion: nil) Inside, I set a clear background with a visual effect view with a blur effect, like this: view.backgroundColor = .clear blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .regular)) //autolayout constraints for the blurEffectView view.addSubview(blurEffectView) But the background remains full white in iOS 26. How can I bring the blur+transparency back like in iOS 18? What am I doing wrong?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
103
3w
iOS 26 UISearchController always appears at the bottom instead of top with preferredSearchBarPlacement = .stacked
Hi everyone, I’m running into a strange issue with UISearchController placement with iOS 26 SDK. In one of my view controllers, I was able to move the search bar to the top of the navigation bar by setting: navigationItem.searchController = searchController navigationItem.hidesSearchBarWhenScrolling = false navigationItem.preferredSearchBarPlacement = .stacked This works as expected — the search bar is placed at the top. However, in another view controller with almost identical configuration, the search bar always shows up at the bottom. If I delay the setup with DispatchQueue.main.async, it appears at the bottom; if I don’t, it doesn’t appear at all. Both VCs are wrapped in their own UINavigationController. So my questions are: Has anyone faced this issue where preferredSearchBarPlacement = .stacked is ignored? Are there hidden requirements or limitations for placing the search bar at the top? Why could the same setup behave differently in two controllers? Any help or ideas would be appreciated!
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
131
3w