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

Posts under UIKit tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

UIKit-xxx.pcm' does not exist
Setting breakpoints in Xcode and debugging the program will output the following information in the console. The first breakpoint debugging is triggered every time you compile and run the program. Furthermore, loading variables during breakpoint debugging takes a very long time. Why is this information outputted? And why does it take so long warning: (arm64) /Users/xxx/Library/Developer/Xcode/DerivedData/MYApp-edwwubwxxruxpddmfzegvkdqhppk/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/FBKVOController/FBKVOController.framework/FBKVOController(FBKVOController.o) '/var/folders/45/h0vrkd951jjbc538flwxctqc0000gn/C/clang/ModuleCache/2OX0YH8X0GZ6V/UIKit-HKJAGZJT5Z2N.pcm' does not existwarning: (arm64) Environment Xcode Version 16.4 (16F6) + any iPhone device
0
0
33
Aug ’25
UITabBarController, menu bar and first responder
I'm using a standard UITabBarController on iPad. When first selecting any tab, the corresponding menu bar items are grayed out for this view controller. It's only when I tap any button in that view controller, like in the toolbar, that the view controller truly becomes the first responder (you can see the sidebar selection turns to gray from blue), enabling those menu bar items. Am I doing something wrong here? A video of the issue can be found here: https://mastodon.social/@nicoreese/114949924393554961 AppDelegate: ... builder.insertChild(MenuController.viewModeMenu(), atStartOfMenu: .view) class func viewModeMenu() -> UIMenu { let listViewModeCommand = UICommand( title: String(localized: "As List"), image: UIImage(systemName: "list.bullet"), action: #selector(GamesViewController.setListViewMode), propertyList: SettingsService.ViewMode.list.rawValue ) ... let viewModeMenu = UIMenu( title: "", image: nil, identifier: .viewModeMenu, options: .displayInline, children: [listViewModeCommand...] ) return viewModeMenu } GamesViewController: @objc func setListViewMode() { updateViewMode(.list) } I can do this, but then the sidebar selection instantly turns gray, which looks odd and other system apps do not behave this way. override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) becomeFirstResponder() } override var canBecomeFirstResponder: Bool { return true }
Topic: UI Frameworks SubTopic: UIKit Tags:
5
0
164
3w
Replacing the Preferences item in a menu bar
Per default the menu bar on iPad includes an application menu named after your app which includes a Preferences action. That one opens the Settings app to your app settings page. I do not really populate that with options and instead have my own settings UI accessible in my app using toolbar items. What's the best approach to handle this with the menu bar? I've tried replacing the default Preferences item but that only works if I do not use its shortcut, which I would like to preserve. Another solution would be to append another Settings item for my UI, which would look weird and confusing, but seems to be the recommended way from the HIG. Reserve the YourAppName > Settings menu item for opening your app’s page in iPadOS Settings. If your app includes its own internal preferences area, link to it with a separate menu item beneath Settings in the same group. Place any other custom app-wide configuration options in this section as well. I take it there is no way to replace it then?
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
116
Jul ’25
iPad menu bar and multiple windows
I'm trying to support the new menu bar in iPadOS 26. In AppDelegate I do this. I want to this to be a global command, which can work regardless of which view controller is currently visible, so I let the AppDelegate handle the selector (if there's a better way let me know). UIMainMenuSystem.shared.setBuildConfiguration(config) { builder in let createCollectionCommand = UIKeyCommand( title: String(localized: "Create Collection"), image: UIImage(systemName: "folder.badge.plus"), action: #selector(AppDelegate.showCreateCollectionViewController), input: "c", modifierFlags: .control ) builder.insertElements([createCollectionCommand], atEndOfMenu: .file) } This works mostly. A problem arrises when I have multiple windows open at the same time. I need a way to determine the currently active window scene from AppDelegate to display a sheet on that window's root view controller. There's stuff like this, but unfortunately all visible windows have activationState == .foregroundActive, so I cannot use that. guard let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene else { return } So, how do I do multi-window global commands? I'm basically looking for something like the "Create Playlist" command in the Music app.
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
102
Jul ’25
UIViewController + AVPlayerLayer + AVPlayer cannot AirPlay to HomePod on tvOS 18.5, but AVPlayerViewController + AVPlayer is ok
1, Devices Apple TV HD tvOS 18.5 (22L572) Mode(A1625) HomePod Gen1 OS18.5 (22L572) 2, Test cases: 2.1 UIViewController + AVPlayerLayer + AVPlayer Result: Can not AirPlay to HomePod Sample code for UIViewController + AVPlayer 2.1 AVPlayerViewController + AVPlayer Result: Can AirPlay to HomePod Sample code for AVPlayerViewController + AVPlayer
0
0
181
Aug ’25
UITabBar hitTest method is not triggered when click button that is a subview of UITabBar and the subview frame is beyond UITabBar when using Xcode26 build app on OS 26
In our project, we defined a CustomTabBar that inherits UITabBar, and we add some subviews and these subviews' frame is beyond UITabBar, see below picture(a beyond area button, this button is a subview of UITabBar, but frame is out of UITabBar's area): and in order to let this button response to click action, we override the UITabBar's hitTest method, this works well below OS 26 with Xcode version below 26: override public func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { let pointInCollectionView = self.beyondAreaButton.convert(point, from: self) if self.beyondAreaButton.bounds.contains(pointInCollectionView) { return self.beyondAreaButton.hitTest(pointInCollectionView, with: event) } return super.hitTest(point, with: event) } but when using Xcode26 build app on OS 26, I noticed the UITabBar is wrapped by a UIKit._UITabBarContainerView and UIKit._UITabBarContainerWrapperView, and it can not trigger the hitTest method. since the hitTest is not triggered, so the button action is no chance to trigger too. Any suggestions to solve this problem, thank you~ And I have file a feedback assistant: FB19252973
1
0
102
Jul ’25
Best Practice for Resizing UITableViewCell Containing WKWebView with DiffableDataSource
Hi everyone, I’m currently working on a UITableView setup that uses UITableViewDiffableDataSource. Each cell contains two views: A UILabel for a title A WKWebView that loads dynamic HTML content My Current Approach: On initial load, I let all cells render with default height. As each WKWebView finishes loading, I calculate its content height using JavaScript and store this height in a [String: CGFloat] dictionary keyed by a unique identifier for each WebView. I then call tableView.performBatchUpdates to trigger a layout update and resize the cell. When the same cell index and data are shown again, I retrieve the cached height from the dictionary and apply it as a constraint on the WKWebView before loading its content. This mostly works, but occasionally, there are visual glitches — such as flickering during scrolling or incorrect cell heights temporarily shown before the height is re-applied. My Questions: Is this a recommended or sustainable way for handling WKWebView inside a UITableViewCell, especially with DiffableDataSource? Are there any known best practices or alternatives to manage dynamic web content heights more smoothly in table cells? Is it possible that the glitches are caused by layout timing issues or reentrancy of height calculation and rendering? Any suggestions, refinements, or architectural recommendations would be greatly appreciated. Thanks in advance!
0
0
39
Jul ’25
4 or 5 Finger Gestures on iPadOS 26
I disable 4 or 5 Finger Gestures on Settings.app > Multi-tasking and Gestures. But in the third-party apps, 4-5 finger touches are sometimes immediately cancelled. Especially, 4-5 finger swipe gesture. I filed this issue to FB19226717. I develop Piano instrument app. 4 or 5 finger touches are required for that kind of apps. Please fix this, Apple.
0
0
79
Jul ’25
iOS 26 web page with script is terminated on custom scheme WKURLSchemeHandler
Something has changed in iOS 26 and now if custom scheme is used and web page contains scripts WebKit is terminated. 0x1130bc170 - [PID=47858] WebProcessProxy::didClose: (web process 0 crash) 0x1130bc170 - [PID=47858] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash final class CustomSchemeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let sampleConfiguration = WKWebViewConfiguration() sampleConfiguration.setURLSchemeHandler( SampleURLSchemeHandler(), forURLScheme: "sample" ) let webView = WKWebView(frame: view.bounds, configuration: sampleConfiguration) webView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(webView) webView.navigationDelegate = self webView.load(URLRequest(url: URL(string: "sample://pages/sample.html")!)) } } extension CustomSchemeViewController: WKNavigationDelegate { func webViewWebContentProcessDidTerminate(_ webView: WKWebView) { print("webViewWebContentProcessDidTerminate") } } final class SampleURLSchemeHandler: NSObject, WKURLSchemeHandler { private func post(_ body: String, mimeType: String, urlSchemeTask: WKURLSchemeTask) { let body = Data(body.utf8) let response = URLResponse( url: urlSchemeTask.request.url!, mimeType: mimeType, expectedContentLength: body.count, textEncodingName: nil ) urlSchemeTask.didReceive(response) urlSchemeTask.didReceive(body) urlSchemeTask.didFinish() } func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) { switch urlSchemeTask.request.url?.lastPathComponent { case "sample.html": post(""" <?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="/scripts/sample.js"></script> </head> <body> <p>Sample</p> </body> </html> """, mimeType: "application/xhtml+xml", urlSchemeTask: urlSchemeTask ) case "sample.js": post("console.log('Hello from JS File')", mimeType: "text/javascript", urlSchemeTask: urlSchemeTask ) default: assertionFailure() } } func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) { print("webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask)") } } It works fine with css file inside, without script tag or with async attribute Code of sample project https://github.com/Igor-Palaguta/iOS26URLSchemeTermination
2
2
157
Aug ’25
Optimizing for the 500 widgets and updating it faster in iOS
I am creating 500 textfield widgets and then updating them and all their 40 properties at once. I require to update all 500 widgets with their properties at once as it is a usecase in our app, so pooling and showing only those that will be on screen won't really help in this case. I have found that for updating all these 500 textfield widgets with their 40 properties, the time taken is 80 to 100 milliseconds. However, if I update the non-string properties like .text, then it comes down to half which is 40 to 50 milliseconds. Wanted to know if there was a far more quicker or optimized way to do this? The following snippet of code shows what I am doing: @objc private func handleImmediateMode() { let startTime = CFAbsoluteTimeGetCurrent() for (index, textField) in retainedInputFields.enumerated() { updateAllProperties(for: textField, index: index) } let endTime = CFAbsoluteTimeGetCurrent() print("Immediate Mode -- (500 fields, 40 props): \( (endTime - startTime) * 1000) ms") } In the above code, I have already created the 500 textfield widget, and then in updateAllProperties () function I am passing the textfield widget to it and then updating the 40 properties that the widget has. Particularily, the following properties: textField.placeholder = "Input Field (index)" UILabel().text Seem to be adding the extra 40 - 50 milliseconds.
0
0
24
Jul ’25
Unable to Tint Custom View in UIBarButtonItem on iOS 26
When using a custom UIButton as the customView for a UIBarButtonItem in iOS 26, setting the tintColor on the UIBarButtonItem or the button itself does not affect the button’s appearance in the navigation bar. The button displays, but the tint is not applied as expected. Steps to Reproduce: Create a new iOS project with a navigation controller. Use the following code in your view controller: class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .secondarySystemBackground var configuration = UIButton.Configuration.plain() configuration.title = "Why Not Tinted...?" configuration.baseForegroundColor = .systemBlue configuration.contentInsets = NSDirectionalEdgeInsets(top: 12, leading: 12, bottom: 12, trailing: 12) let button = UIButton(configuration: configuration) let rightBarButton = UIBarButtonItem(customView: button) rightBarButton.tintColor = .green navigationItem.rightBarButtonItem = rightBarButton } } Expected Result: The UIButton in the navigation bar should appear green with glass effect, according to the tintColor set on the UIBarButtonItem. Actual Result: The UIButton appears, but the tintColor is not applied. Changing the tintColor on either the UIBarButtonItem or the UIButton has no effect on its appearance in the navigation bar.
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
99
3w
UICollectionViewDataSourcePrefetching does not work on SwiftUI wrapped VisionOS
prefetching logic for UICollectionView on VisionOS does not work. I have set up a Standalone test repo to demonstrate this issue. This repo is basically a visionOS version of Apple's guide project on implementation of prefetching logic. in repo you will see a simple ViewController that has UICollectionView, wrapped inside UIViewControllerRepresentable. on scroll, it should print 🕊️ prefetch start on console to demonstrate func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) is called. However it never happens on VisionOS devices. With the same code it behaves correctly on iOS devices
1
0
127
Jul ’25
UIAlertAction.isEnabled = false Has No Visual Effect on iOS 26 (Action Still Looks Enabled)
Hi all, I'm running into a UIKit issue specific to iOS 26 (Xcode 26 Beta 4) where UIAlertAction buttons that are disabled using .isEnabled = false do not appear visually disabled. The alert still shows the action with full opacity and default styling, making it look like the button is tappable — even though it isn't. ❗ Issue: On iOS 26, disabled actions in UIAlertController no longer appear dimmed or inactive. This is a visual regression compared to iOS 18 and earlier, where disabled actions would automatically appear grayed out and visually distinct.
Topic: UI Frameworks SubTopic: UIKit Tags:
2
0
100
Jul ’25
Why my font size is not scaling dynamically
Hello everyone, I am having an issue where the attributed text that I have in my UITextView is not scaling dynamically with phone text size, whenever I remove the attributed text logic, it scales fine, however, with it, it stays at a set font size. struct AutoDetectedClickableDataView: UIViewRepresentable { let text: String @Binding var height: CGFloat func makeUIView(context: Context) -> UITextView { let textView = UITextView() textView.dataDetectorTypes = [.phoneNumber, .address, .link] textView.isEditable = false textView.isScrollEnabled = false textView.backgroundColor = .clear textView.font = UIFont.preferredFont(forTextStyle: .body) /*UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont.systemFont(ofSize: 16.0)) */ textView.adjustsFontForContentSizeCategory = true textView.textContainer.lineBreakMode = .byWordWrapping textView.textContainerInset = .zero textView.textContainer.lineFragmentPadding = 0 textView.translatesAutoresizingMaskIntoConstraints = false textView.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) textView.setContentHuggingPriority(.defaultHigh, for: .horizontal) return textView } func updateUIView(_ uiView: UITextView, context: Context) { let attributed = NSMutableAttributedString(string: text, attributes: [ .font: UIFont.preferredFont(forTextStyle: .body) ]) let detector = try? NSDataDetector(types: NSTextCheckingResult.CheckingType.address.rawValue | NSTextCheckingResult.CheckingType.link.rawValue | NSTextCheckingResult.CheckingType.phoneNumber.rawValue) detector?.enumerateMatches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count)) { match, _, _ in guard let match = match else { return } attributed.addAttributes([ .foregroundColor: UIColor.systemBlue, .underlineStyle: NSUnderlineStyle.single.rawValue, ], range: match.range) } uiView.attributedText = attributed // uiView.text = text DispatchQueue.main.async { uiView.layoutIfNeeded() let fittingSize = CGSize(width: uiView.bounds.width, height: .greatestFiniteMagnitude) let size = uiView.sizeThatFits(fittingSize) height = size.height } } }
1
0
323
Jul ’25
Xcode 26 Beta Crash on iOS 18 and below – UIToolbar in XIB/Storyboard Causes
Hey everyone, Just wanted to share a critical issue we’ve encountered while testing our app on iOS 18 simulators and devices using Xcode 26 Beta 3: Crash Details We're seeing the following fatal exception during launch: NSInvalidUnarchiveOperationException Could not instantiate class named _TtGC5UIKit17UICoreHostingViewVCS_21ToolbarVisualProvider8RootView_ because no class named _TtGC5UIKit17UICoreHostingViewVCS_21ToolbarVisualProvider8RootView_ was found... The crash originates from Storyboards/XIBs that include a UIToolbar. It appears UIKit is referencing an internal SwiftUI-related class (UICoreHostingView), which isn't present at runtime — leading to immediate crashes. Affected: Apps using UIToolbar in Storyboards or XIBs Running on iOS 18 (Simulators or Devices) and below Built using Xcode 26 Beta 3 CrashLog: Fatal Exception: NSInvalidUnarchiveOperationException 0 CoreFoundation 0x11a21c __exceptionPreprocess 1 libobjc.A.dylib 0x31abc objc_exception_throw 2 CoreFoundation 0x178ea0 -[NSException initWithCoder:] 3 UIFoundation 0x28774 UINibDecoderDecodeObjectForValue 4 UIFoundation 0x28a18 UINibDecoderDecodeObjectForValue 5 UIFoundation 0x28cac -[UINibDecoder decodeObjectForKey:] 6 UIKitCore 0x21e680 -[UIView initWithCoder:] 7 UIKitCore 0x9b4784 -[UIToolbar initWithCoder:] 8 UIFoundation 0x28890 UINibDecoderDecodeObjectForValue 9 UIFoundation 0x28cac -[UINibDecoder decodeObjectForKey:] 10 UIKitCore 0x1e3a80 -[UIRuntimeConnection initWithCoder:] 11 UIFoundation 0x28890 UINibDecoderDecodeObjectForValue 12 UIFoundation 0x28a18 UINibDecoderDecodeObjectForValue 13 UIFoundation 0x28cac -[UINibDecoder decodeObjectForKey:] 14 UIKitCore 0x1e87dc -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] 15 UIKitCore 0x1e2ea4 -[UINib instantiateWithOwner:options:] 16 UIKitCore 0x9f96c -[UIViewController loadView] 17 UIKitCore 0x75da8 -[UIViewController loadViewIfRequired] 18 UIKitCore 0x14430 -[UIViewController view] 19 UIKitCore 0x4237bc -[UINavigationController _preferredContentSizeForcingLoad:] 20 UIKitCore 0x116b15c -[_UISheetPresentationMetrics formSheetSizeForViewController:windowSize:screenSize:] 21 UIKitCore 0xb5c60c -[UIViewController _formSheetSizeForWindowWithSize:screenSize:] 22 UIKitCore 0x546ebc -[_UISheetLayoutInfo _preferredSize] 23 UIKitCore 0x18da60 -[_UISheetLayoutInfo _isEdgeAttached] 24 UIKitCore 0x19d428 -[_UISheetLayoutInfo _margins] 25 UIKitCore 0x19ce88 -[_UISheetLayoutInfo _stackAlignmentFrame] 26 UIKitCore 0x211018 -[_UISheetLayoutInfo _fullHeightUntransformedFrame] 27 UIKitCore 0x18f39c -[_UISheetLayoutInfo _untransformedFrame] 28 UIKitCore 0x188350 -[UISheetPresentationController _containerViewLayoutSubviews] 29 UIKitCore 0x18f1fc -[UITransitionView layoutSubviews] 30 UIKitCore 0x26070 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] 31 QuartzCore 0x14c14 CA::Layer::layout_if_needed(CA::Transaction*) 32 UIKitCore 0x16b78 -[UIView(Hierarchy) layoutBelowIfNeeded] 33 UIKitCore 0x186f4c -[UISheetPresentationController presentationTransitionWillBegin] 34 UIKitCore 0x3187b4 -[_UIFormSheetPresentationController presentationTransitionWillBegin] 35 UIKitCore 0x185dd0 __80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke 36 UIKitCore 0x1874f8 __77-[UIPresentationController runTransitionForCurrentStateAnimated:handoffData:]_block_invoke_3 37 UIKitCore 0x8584c -[_UIAfterCACommitBlock run] 38 UIKitCore 0x85784 -[_UIAfterCACommitQueue flush] 39 UIKitCore 0xa254 _runAfterCACommitDeferredBlocks 40 UIKitCore 0x9f74 _cleanUpAfterCAFlushAndRunDeferredBlocks 41 UIKitCore 0x9e84 _UIApplicationFlushCATransaction 42 UIKitCore 0x9e0c __setupUpdateSequence_block_invoke_2 43 UIKitCore 0x9404 _UIUpdateSequenceRun 44 UIKitCore 0x8ab4 schedulerStepScheduledMainSection 45 UIKitCore 0x41e4 runloopSourceCallback 46 CoreFoundation 0xfa8c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 47 CoreFoundation 0xf8a4 __CFRunLoopDoSource0 48 CoreFoundation 0xf700 __CFRunLoopDoSources0 49 CoreFoundation 0x10080 __CFRunLoopRun 50 CoreFoundation 0x11c3c CFRunLoopRunSpecific 51 GraphicsServices 0x1454 GSEventRunModal 52 UIKitCore 0x135274 -[UIApplication _run] 53 UIKitCore 0x100a28 UIApplicationMain 54 Saleslink DEV 0x1f9ea8 main + 17 (AppDelegate.swift:17) 55 ??? 0x1af61bf08 (Missing) Would love to know if anyone else has encountered this, or if there’s an official radar or feedback ID we can follow. Hoping this gets resolved before the GM release of Xcode 26. Thanks!
2
1
241
Jul ’25
For the property modifiers of XIB controls, should we use strong or weak?
In our current code, the properties of XIB controls are added with weak. However, we encounter some crashes due to accessing wild pointers of controls when a memory warning occurs. Colleagues from our architecture team said that they had specifically consulted Apple's technical staff before, and the reply was that strong should be used for modification, as it would make the memory more stable. They also mentioned that the statement in the official documentation is incorrect and hasn't been updated. May I ask whether strong or weak should be used for XIB control properties? What is your latest standard answer?
Topic: UI Frameworks SubTopic: UIKit Tags:
4
0
104
3w
Section Header Overlaps with Cell Text in Plain List Style on iOS 26
Hi everyone, I've noticed that on iOS 26 beta 1 through beta 4, when using a List with the .plain style, the section header overlaps with the cell content below it, as there is no background for the header. This creates a poor visual experience. Additionally, when using NavigationSplitView on iPad, the second column's list always shows this issue. Is this an intentional design change, or just a temporary issue? I haven't found a good workaround so far. Thanks! FB19066489
0
1
550
Jul ’25
Incorrect safeAreaInsets.top on iPhone SE (2nd/3rd gen) – iOS 26 Beta
On iPhone SE (2nd/3rd generation) running iOS 26 beta , the safeAreaInsets.top unexpectedly returns 0 instead of the expected 20 points, causing UI elements that rely on safe area layout to be overlapped by the status bar. You can see that i works fine with iOS 18, whereas iOS 26 the status bar is overlapped. Is this a known bug or there is new API changes that I might not be aware of.
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
316
3w
Right bar button items in iOS 26 visual presentation
I have attached two images of two screens below. In one screen, bar button are enclosed within separate, distinct, rounded-rectangle 'liquid glass' capsules. In other screen, bar buttons are enclosed within separate, distinct, rounded-rectangle "liquid glass" capsules. They are not visually merged into one larger capsule. Both are having same code. But why it is not same ?
1
0
92
Jul ’25