JUST ENDED
|

UIKit Q&A

Connect with Apple engineers in the UIKit Q&A on the Apple Developer Forums.

Post

Replies

Boosts

Views

Activity

Correct UIScene Configuration for UISceneAccessory
What is the correct configuration of the Info.plist to get a UISceneAccessory to display on an external monitor? I'm currently getting: Info.plist contained no UIScene configuration dictionary (looking for configuration named "scene-accessory") My Info.plist looks as follows: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <true/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleExternalDisplayNonInteractive</key> <array> <dict> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).AccessorySceneDelegate</string> <key>UISceneConfigurationName</key> <string>scene-accessory</string> </dict> </array> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> </dict> </array> </dict> </dict> </dict> </plist> And the view controller scene registration code: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let sceneConfiguration = UISceneConfiguration(name: "scene-accessory") let accessory = UISceneAccessory.externalNonInteractive(sceneConfiguration: sceneConfiguration) let registration = registerSceneAccessory(accessory) registration.isEnabled = true } } Thanks!
Topic: UI Frameworks SubTopic: UIKit
1
0
46
11h
How to display UISplitViewController columns next to each other again.
Since iOS26 the UISplitViewController is displayed in a way where the primary column (red) overlaps the secondary column (blue) instead of displaying them next to each other like before. Several Apple apps still display the columns next to each other, like Notes, Mail and Photos. What is the correct way to display the columns next to each other again using UIKit and if possible Storyboards.
Topic: UI Frameworks SubTopic: UIKit
4
0
53
11h
What could cause a UIViewController to get viewDidLoad twice and never get viewWillAppear or viewDidAppear?
I've gotten diagnostics from a couple of my users experiencing a rare issue. The logs in the diagnostics clearly show that the view controller where the issue occurs gets viewDidLoad called twice, and then does not get viewWillAppear or viewDidAppear. This triggers a bug for me because the view controller loads the data it's meant to display in viewWillAppear. I can work around this by changing my data loading logic, but I'd like to know what the underlying issue is. Can anyone point me to some possible ways I could be triggering this weird UIKit behavior?
Topic: UI Frameworks SubTopic: UIKit
1
0
54
11h
What's the best way to have non-trivially-sized views scroll with text in a UITextView?
I've got a note editor view in my app that's built around a UITextView. At the top of the text view, it displays some metadata about the note, like location of the note (it's an e-reader app - think highlighting text and adding a note to it). I want this metadata to be able to scroll out of view if you scroll down in the text view. But it shouldn't simply be text in the text view - it's a UIView that takes the full width of the text view, with some UILabels in it. The height is on the order of 60 points tall. What's the best way to achieve this? Should the view that contains the labels be in a text attachment? Or should it be a subview of the UITextView? Or should I do something custom like make it a subview of the view that contains the UITextView and watch the UITextView's scroll position and apply a transform to move it to match?
Topic: UI Frameworks SubTopic: UIKit
2
0
41
11h
When the marked text is touched, or when the cursor is moved between the marked text, the marked text will be disappear
When the marked text is touched, or when the cursor is moved between the marked text, the marked text will be disappear In order to implement the function of active input, we use the setMarkedText(_:selectedRange:) method provided by UITextDocumentProxy to insert and mark the input text, but when the marked text is touched, or when the cursor is moved between the text, the marked text will be disappear. This is a very obvious error and cannot be avoided. So far, this problem still occurs on devices with the system version of iOS 27 beta , so we cannot use this method to perfectly implement the function of active input, which is a big trouble for us. We want the text to be displayed normally after the user touches the marked text. And the cursor can move in the marked text, so that the user can perform operations such as insert, remove, etc. May I ask what methods can be used to achieve the above effect? If this is a bug, please fix it as soon as possible. More details can be found by the video link: [https://www.youtube.com/shorts/dd8VhBJ88og] STEPS TO REPRODUCE 1.Use the setMarkedText(_:selectedRange:) method provided by UITextDocumentProxy to insert and mark text 2.Touch the marked text or long press the cursor to move to the marked text
Topic: UI Frameworks SubTopic: UIKit
1
0
67
12h
Supplying custom menu elements to a UITextView's edit menu
When appending additional UIAction children to the horizontal edit menu UIMenu returned in the delegate method func textView(_ textView: UITextView, editMenuForTextIn range: NSRange, suggestedActions: [UIMenuElement]) -> UIMenu? If the menu is long enough to need an overflow chevron vertical menu (introduced in iOS 26) my UIAction only show either a title or an image not both, is UIAction the right UIMenuElement type to supply here? How to get both the title and the image to appear in the overflow vertical menu?
Topic: UI Frameworks SubTopic: UIKit
3
0
53
12h
Text system improvements
For developing an iOS fully-featured code editor (i.e line numbers + color pass for syntax highlighting + collapsible sections + debug markers/highlights) what would be the best strategy for iOS 27? UITextView with new viewport control delegate Custom TextKit2 UIView Custom TextKit1 UIView (this was the recommendation I got as of WWDC25)
Topic: UI Frameworks SubTopic: UIKit
4
0
97
12h
Updates on Storyboards
In the past few years, there hasn't been much updates around Storyboards and yet it seems like Xcode supports them. Even before the first release of SwiftUI, many developers stopped using Storyboards for compelling reasons such as: They introduce two sources of truth for the UI It's not easy to read the content during code-review They can cause merge conflicts Often they fail to load, especially after a new major release of Xcode, without any error I was wondering whether there's a dedicated team working on Storyboards or if they're just abandoned. I understand this question may overlap with what the Xcode team does; so, let me rephrase it: in a large project, what are the pros and cons of using Storyboards when building views using UIKit? For instance, do they work well with things such as navigation by employing segues, the liquid glass or the new resizing feature? Finally, one of the benefits of using Storyboards is the fact that they visualize the UI, including the constraints. However, since now we can UIViewController in Preview, can we safely say that Previews can deliver the same thing?
Topic: UI Frameworks SubTopic: UIKit
1
0
59
12h
Variable-height rows in UITableView
I am giving the user a view onto a selection of database records. There could be a handful of these, there could be 10,000 of them. At present I use a UITableView. Cells are therefore created or recycled on demand. When a cell is created, it is displayed with default "empty" contents and it sends a message to the server to request a record. When the record arrives, the cell is then able to change its own contents so that the record appears on the screen. There are of course various optimisations, such as cancelling a request if the cell goes offscreen before a reply is received; or delaying a request if it looks as if the cell will end up being off the screen once scrolling has stopped. All this happens with fixed-height cells. Accordingly the UITableView has all the data it needs to work out where every one of the 10,000 cells is. I now want to extend this to variable-height cells. That is: cells whose height depends on the content received from the database. Accordingly, when a cell receives its data it may find itself having to change its own size. Is this structure practicable with UITableView?
Topic: UI Frameworks SubTopic: UIKit
2
0
59
12h
UISlider.TrackConfiguration.Tick title and image Values
What is the expected behaviour of UISlider.TrackConfiguration.Tick's title and image properties? On iOS, these seem to be no-ops. The docs also don't indicate what these properties do. let ticks = [ UISlider.TrackConfiguration.Tick(position: 0, title: "Slow", image: UIImage(systemName: "tortoise.fill")), UISlider.TrackConfiguration.Tick(position: 1, title: "Fast", image: UIImage(systemName: "hare.fill")) ] let configuration = UISlider.TrackConfiguration(ticks: ticks) let slider = UISlider() slider.trackConfiguration = configuration
Topic: UI Frameworks SubTopic: UIKit
1
0
25
12h
UITabBarController prominentTabIdentifier as Action Behaviour
UITabBarController's new prominentTabIdentifier property is a really nice addition! Thank you! Will there be official support via the UITab API for using the underlying _UITabBarAuxiliaryView as a primary action as many apps, such as the Apple Design Award Finalist, Structured, does for presenting a sheet, for example?
Topic: UI Frameworks SubTopic: UIKit
1
0
27
12h
UIWritingToolsCoordinator isWritingToolsAvailable Functionality on iOS 27
The docs for UIWritingToolsCoordinator's isWritingToolsAvailable have been updated in the 27 SDK. Previously, the docs stated: Writing Tools support might be unavailable because of device constraints or because the system isn’t ready to process Writing Tools requests. They now say: Writing Tools support might be unavailable because of device constraints. Is this a change in behaviour between SDK 26 and 27, or have the docs just been updated to more accurately describe the behaviour?
Topic: UI Frameworks SubTopic: UIKit
1
0
85
12h
iOS 27 recommendation
For apps still using UIKit view controllers presented over a SwiftUI hierarchy (or vice versa), what's the recommended approach in iOS 27 for finding the correct presenting context across the new window scene configurations, especially with resizable windows? — Divya Ravi, Senior iOS Engineer
Topic: UI Frameworks SubTopic: UIKit
1
0
75
12h
UIScreen.main is deprecated
We have unit test targets that do not need a host app. However, when running snapshot tests (using frameworks such as swift-snapshot-testing), we'd like to read some properties on UIScreen.main. For instance, we'd like to assert that the scale of the simulator that's being used is matching our expectation. Without using a host app, there's no connected UIScene on UIWindow.shared.connectedScenes. Questions: Why UIScreen.main was deprecated? In our case, how can we get the scale property without attaching a host app to our test target? In other words, without using UIWindow.shared.connectedScenes.
Topic: UI Frameworks SubTopic: UIKit
1
1
73
13h
UITextView for displaying long text?
My app displays vertically scrollable text to the user which could be as short as a single screen or as long as a book chapter: imagine something like an e-book reader which uses scrolling rather than page-turning. A long time ago when development first started, I tried using UITextView, but the size of text that could be handled was quite limited (a figure of 32767 points seems to stick in the memory). Accordingly I came up with a custom solution in which a UIScrollView handled scrolling gestures and a custom UIView rendered just the part of the text that was visible at that time. That works, but it becomes cumbersome to add support for features such as selection handles and loupes. 18 years later, is there a more smoothly integrated way of displaying long scrollable text?
Topic: UI Frameworks SubTopic: UIKit
1
0
38
13h
Correct UIScene Configuration for UISceneAccessory
What is the correct configuration of the Info.plist to get a UISceneAccessory to display on an external monitor? I'm currently getting: Info.plist contained no UIScene configuration dictionary (looking for configuration named "scene-accessory") My Info.plist looks as follows: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <true/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleExternalDisplayNonInteractive</key> <array> <dict> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).AccessorySceneDelegate</string> <key>UISceneConfigurationName</key> <string>scene-accessory</string> </dict> </array> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> </dict> </array> </dict> </dict> </dict> </plist> And the view controller scene registration code: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let sceneConfiguration = UISceneConfiguration(name: "scene-accessory") let accessory = UISceneAccessory.externalNonInteractive(sceneConfiguration: sceneConfiguration) let registration = registerSceneAccessory(accessory) registration.isEnabled = true } } Thanks!
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
46
Activity
11h
How to display UISplitViewController columns next to each other again.
Since iOS26 the UISplitViewController is displayed in a way where the primary column (red) overlaps the secondary column (blue) instead of displaying them next to each other like before. Several Apple apps still display the columns next to each other, like Notes, Mail and Photos. What is the correct way to display the columns next to each other again using UIKit and if possible Storyboards.
Topic: UI Frameworks SubTopic: UIKit
Replies
4
Boosts
0
Views
53
Activity
11h
What could cause a UIViewController to get viewDidLoad twice and never get viewWillAppear or viewDidAppear?
I've gotten diagnostics from a couple of my users experiencing a rare issue. The logs in the diagnostics clearly show that the view controller where the issue occurs gets viewDidLoad called twice, and then does not get viewWillAppear or viewDidAppear. This triggers a bug for me because the view controller loads the data it's meant to display in viewWillAppear. I can work around this by changing my data loading logic, but I'd like to know what the underlying issue is. Can anyone point me to some possible ways I could be triggering this weird UIKit behavior?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
54
Activity
11h
What's the best way to have non-trivially-sized views scroll with text in a UITextView?
I've got a note editor view in my app that's built around a UITextView. At the top of the text view, it displays some metadata about the note, like location of the note (it's an e-reader app - think highlighting text and adding a note to it). I want this metadata to be able to scroll out of view if you scroll down in the text view. But it shouldn't simply be text in the text view - it's a UIView that takes the full width of the text view, with some UILabels in it. The height is on the order of 60 points tall. What's the best way to achieve this? Should the view that contains the labels be in a text attachment? Or should it be a subview of the UITextView? Or should I do something custom like make it a subview of the view that contains the UITextView and watch the UITextView's scroll position and apply a transform to move it to match?
Topic: UI Frameworks SubTopic: UIKit
Replies
2
Boosts
0
Views
41
Activity
11h
Reproducing the date label above the editor scroll/text view in Journal and Notes app
I made a few attempts to implement a similar label but I'm not sure if it's possible using public APIs. Could you give any tips about how to approach implementing this? Thank you!
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
77
Activity
12h
When the marked text is touched, or when the cursor is moved between the marked text, the marked text will be disappear
When the marked text is touched, or when the cursor is moved between the marked text, the marked text will be disappear In order to implement the function of active input, we use the setMarkedText(_:selectedRange:) method provided by UITextDocumentProxy to insert and mark the input text, but when the marked text is touched, or when the cursor is moved between the text, the marked text will be disappear. This is a very obvious error and cannot be avoided. So far, this problem still occurs on devices with the system version of iOS 27 beta , so we cannot use this method to perfectly implement the function of active input, which is a big trouble for us. We want the text to be displayed normally after the user touches the marked text. And the cursor can move in the marked text, so that the user can perform operations such as insert, remove, etc. May I ask what methods can be used to achieve the above effect? If this is a bug, please fix it as soon as possible. More details can be found by the video link: [https://www.youtube.com/shorts/dd8VhBJ88og] STEPS TO REPRODUCE 1.Use the setMarkedText(_:selectedRange:) method provided by UITextDocumentProxy to insert and mark text 2.Touch the marked text or long press the cursor to move to the marked text
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
67
Activity
12h
Supplying custom menu elements to a UITextView's edit menu
When appending additional UIAction children to the horizontal edit menu UIMenu returned in the delegate method func textView(_ textView: UITextView, editMenuForTextIn range: NSRange, suggestedActions: [UIMenuElement]) -> UIMenu? If the menu is long enough to need an overflow chevron vertical menu (introduced in iOS 26) my UIAction only show either a title or an image not both, is UIAction the right UIMenuElement type to supply here? How to get both the title and the image to appear in the overflow vertical menu?
Topic: UI Frameworks SubTopic: UIKit
Replies
3
Boosts
0
Views
53
Activity
12h
Text system improvements
For developing an iOS fully-featured code editor (i.e line numbers + color pass for syntax highlighting + collapsible sections + debug markers/highlights) what would be the best strategy for iOS 27? UITextView with new viewport control delegate Custom TextKit2 UIView Custom TextKit1 UIView (this was the recommendation I got as of WWDC25)
Topic: UI Frameworks SubTopic: UIKit
Replies
4
Boosts
0
Views
97
Activity
12h
Updates on Storyboards
In the past few years, there hasn't been much updates around Storyboards and yet it seems like Xcode supports them. Even before the first release of SwiftUI, many developers stopped using Storyboards for compelling reasons such as: They introduce two sources of truth for the UI It's not easy to read the content during code-review They can cause merge conflicts Often they fail to load, especially after a new major release of Xcode, without any error I was wondering whether there's a dedicated team working on Storyboards or if they're just abandoned. I understand this question may overlap with what the Xcode team does; so, let me rephrase it: in a large project, what are the pros and cons of using Storyboards when building views using UIKit? For instance, do they work well with things such as navigation by employing segues, the liquid glass or the new resizing feature? Finally, one of the benefits of using Storyboards is the fact that they visualize the UI, including the constraints. However, since now we can UIViewController in Preview, can we safely say that Previews can deliver the same thing?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
59
Activity
12h
Variable-height rows in UITableView
I am giving the user a view onto a selection of database records. There could be a handful of these, there could be 10,000 of them. At present I use a UITableView. Cells are therefore created or recycled on demand. When a cell is created, it is displayed with default "empty" contents and it sends a message to the server to request a record. When the record arrives, the cell is then able to change its own contents so that the record appears on the screen. There are of course various optimisations, such as cancelling a request if the cell goes offscreen before a reply is received; or delaying a request if it looks as if the cell will end up being off the screen once scrolling has stopped. All this happens with fixed-height cells. Accordingly the UITableView has all the data it needs to work out where every one of the 10,000 cells is. I now want to extend this to variable-height cells. That is: cells whose height depends on the content received from the database. Accordingly, when a cell receives its data it may find itself having to change its own size. Is this structure practicable with UITableView?
Topic: UI Frameworks SubTopic: UIKit
Replies
2
Boosts
0
Views
59
Activity
12h
UISlider.TrackConfiguration.Tick title and image Values
What is the expected behaviour of UISlider.TrackConfiguration.Tick's title and image properties? On iOS, these seem to be no-ops. The docs also don't indicate what these properties do. let ticks = [ UISlider.TrackConfiguration.Tick(position: 0, title: "Slow", image: UIImage(systemName: "tortoise.fill")), UISlider.TrackConfiguration.Tick(position: 1, title: "Fast", image: UIImage(systemName: "hare.fill")) ] let configuration = UISlider.TrackConfiguration(ticks: ticks) let slider = UISlider() slider.trackConfiguration = configuration
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
25
Activity
12h
UITabBarController prominentTabIdentifier as Action Behaviour
UITabBarController's new prominentTabIdentifier property is a really nice addition! Thank you! Will there be official support via the UITab API for using the underlying _UITabBarAuxiliaryView as a primary action as many apps, such as the Apple Design Award Finalist, Structured, does for presenting a sheet, for example?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
27
Activity
12h
What is the performance improvement in UIKit on iOS27?
What improvements have been made in iOS27, and what can we expect to see in terms of performance enhancements in UIKit this year? How would these changes help enhance our app’s user experience?
Topic: UI Frameworks SubTopic: UIKit
Replies
0
Boosts
0
Views
56
Activity
12h
UISceneDelegate migration - firm deadline?
I have not yet completed the migration to scene delegate. If I still build with Xcode 26, will my app continue to launch on iOS 27 even if I release updates (still built with Xcode 26) after the iOS 27 release?
Topic: UI Frameworks SubTopic: UIKit
Replies
3
Boosts
0
Views
73
Activity
12h
UIWritingToolsCoordinator isWritingToolsAvailable Functionality on iOS 27
The docs for UIWritingToolsCoordinator's isWritingToolsAvailable have been updated in the 27 SDK. Previously, the docs stated: Writing Tools support might be unavailable because of device constraints or because the system isn’t ready to process Writing Tools requests. They now say: Writing Tools support might be unavailable because of device constraints. Is this a change in behaviour between SDK 26 and 27, or have the docs just been updated to more accurately describe the behaviour?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
85
Activity
12h
UILookToScrollInteraction Versus UIScrollView.lookToScrollAxes
How does using the new +[UILookToScrollInteraction exclusionRegionInteraction]differ from setting a UIScrollView's lookToScrollAxes to an empty option set? Is UILookToScrollInteraction designed to be applied to scroll edge element containers?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
49
Activity
12h
iOS 27 recommendation
For apps still using UIKit view controllers presented over a SwiftUI hierarchy (or vice versa), what's the recommended approach in iOS 27 for finding the correct presenting context across the new window scene configurations, especially with resizable windows? — Divya Ravi, Senior iOS Engineer
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
75
Activity
12h
UIScreen.main is deprecated
We have unit test targets that do not need a host app. However, when running snapshot tests (using frameworks such as swift-snapshot-testing), we'd like to read some properties on UIScreen.main. For instance, we'd like to assert that the scale of the simulator that's being used is matching our expectation. Without using a host app, there's no connected UIScene on UIWindow.shared.connectedScenes. Questions: Why UIScreen.main was deprecated? In our case, how can we get the scale property without attaching a host app to our test target? In other words, without using UIWindow.shared.connectedScenes.
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
1
Views
73
Activity
13h
UISplitViewController primary column differences in 27 vs 26
The primary column sidebar in iPadOS 26 has a 10pt padding (not sure if we can access this value programmatically) which we hard-coded for edge inset calculations of the secondary view. It appears this padding is still present with the new design. Can we derive this property reliably somehow?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
1
Views
36
Activity
13h
UITextView for displaying long text?
My app displays vertically scrollable text to the user which could be as short as a single screen or as long as a book chapter: imagine something like an e-book reader which uses scrolling rather than page-turning. A long time ago when development first started, I tried using UITextView, but the size of text that could be handled was quite limited (a figure of 32767 points seems to stick in the memory). Accordingly I came up with a custom solution in which a UIScrollView handled scrolling gestures and a custom UIView rendered just the part of the text that was visible at that time. That works, but it becomes cumbersome to add support for features such as selection handles and loupes. 18 years later, is there a more smoothly integrated way of displaying long scrollable text?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
38
Activity
13h