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

Posts under UIKit tag

200 Posts

Post

Replies

Boosts

Views

Activity

Click on UITextView or UITextField to crash
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x115fadbc0' *** First throw call stack: (0x1940bd8c8 0x1910097c4 0x194159838 0x19403a4f8 0x1940423a0 0x1e42cb9a8 0x1e42ce220 0x106f02c08 0x1080a461c 0x1080be2b0 0x1080acb2c 0x1080ad7b4 0x1080b9b00 0x1080b91a4 0x1eecdb3b8 0x1eecda8c0) libc++abi: terminating due to uncaught exception of type NSException InputAnalytics called timeIntervalSinceReferenceDate in dispatch_sync.The display issue of the call stack occurs in two stages: keyboard input analysis and folding the keyboard.After adding protection to NSString, it can function normally, but I want to know the reason. #import "NSString+Safe.h" @implementation NSString (Safe) - (NSTimeInterval)timeIntervalSinceReferenceDate { return 0; } - (NSTimeInterval)timeIntervalSinceDate:(NSDate *)date { return 0; } @end
3
0
107
Oct ’25
preferredImageDynamicRange is not marked as being available only for iOS 17 and above.
open var isAnimating: Bool { get } /// The preferred treatment to use for HDR images. By default the image view will defer to the value from its traitCollection. open var preferredImageDynamicRange: UIImage.DynamicRange /// The resolved treatment to use for HDR images. open var imageDynamicRange: UIImage.DynamicRange { get } This attribute is not marked as being applicable only in iOS 17+ versions. When viewing the UIImageView code in Xcode, the @available(iOS 17.0, *) annotation was not added, which resulted in successful compilation but caused a crash on iOS 16 devices.
3
0
89
Sep ’25
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
62
Sep ’25
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
40
Sep ’25
Click on UITextView or UITextField to crash
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x115fadbc0' *** First throw call stack: (0x1940bd8c8 0x1910097c4 0x194159838 0x19403a4f8 0x1940423a0 0x1e42cb9a8 0x1e42ce220 0x106f02c08 0x1080a461c 0x1080be2b0 0x1080acb2c 0x1080ad7b4 0x1080b9b00 0x1080b91a4 0x1eecdb3b8 0x1eecda8c0) libc++abi: terminating due to uncaught exception of type NSException InputAnalytics called timeIntervalSinceReferenceDate in dispatch_sync.The display issue of the call stack occurs in two stages: keyboard input analysis and folding the keyboard. After adding protection to NSString, it can function normally, but I want to know the reason #import "NSString+Safe.h" @implementation NSString (Safe) - (NSTimeInterval)timeIntervalSinceReferenceDate { return 0; } - (NSTimeInterval)timeIntervalSinceDate:(NSDate *)date { return 0; } @end
1
0
89
Sep ’25
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
77
Sep ’25
Avoid using a segmented control in a toolbar
Hi, in the Human Interface Guidelines, Apple writes: Avoid using a segmented control in a toolbar. Toolbar items act on the current screen — they don’t let people switch contexts like segmented controls do. Along with this image: Source I'm confused by this example. The screenshot seems to be showing a segmented control in a toolbar. Is this saying that the Phone app's All/Missed toggle is different from a segmented control? Under iOS 26 it seems to take a different style compared to a regular segmented control. If so, which component is used to create this filter? Could you please clarify the guidelines? Thank you.
1
0
348
Sep ’25
AppIcon not showing in MacAppstore and Testflight in Tahoe
We’ve been using the new Icon Composer–generated app icons for our existing universal bundle (iOS + Mac Catalyst) app. The icons work perfectly for iOS on the App Store. On macOS Tahoe (macOS 26), however, the App Store listing doesn’t display the app icon — it just shows placeholder while downloading. After the app is installed, the icon displays fine everywhere (Dock, Finder, Launchpad, etc.). Setup: using .iconset generated via Icon Composer, bundled with .png inside the .icon file. On older macOS App Stores, the app icon shows as expected. On Tahoe App Store only, the issue appears. Could this be because the App Store expects .svg variants inside the .icon file for proper display in the Store? Or is there any updated requirement for Mac App Store metadata icons vs. bundled app icons? Any guidance would be much appreciated.
3
1
157
Sep ’25
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
99
Sep ’25
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
272
Sep ’25
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
157
Sep ’25
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
92
Sep ’25
Liquid Glass
I think in the next updates of IOS 26 that Apple should add a setting to enable/disable Liquid Glass because we all know that everybody doesnt like the new update.
Topic: Design SubTopic: General Tags:
1
3
741
Sep ’25
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
113
Sep ’25
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
149
Sep ’25
some unicode string crash in iOS 26 (Core Text)
‏‏‏آلَحـ🇾🇪‏ᬼ⃝⃡Wٌـّاج this string cause a crash on iOS 26 when sett label.text Crashed: com.apple.main-thread 0 CoreText 0xf720c std::__1::__hash_table<std::__1::__hash_value_type<long, CGPoint>, std::__1::__unordered_map_hasher<long, std::__1::__hash_value_type<long, CGPoint>, std::__1::hash, std::__1::equal_to, true>, std::__1::__unordered_map_equal<long, std::__1::__hash_value_type<long, CGPoint>, std::__1::equal_to, std::__1::hash, true>, std::__1::allocator<std::__1::__hash_value_type<long, CGPoint>>>::erase(std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<long, CGPoint>, void*>>) + 300 1 CoreText 0xf63d4 TGlyphComposer::ComposeGlyphs(long, TInlineVector<unsigned short, 30ul> const&, TInlineVector<long, 30ul> const&) + 2896 2 CoreText 0x8b018 TCombiningEngine::ResolveCombiningMarks(TCombiningEngine::CombiningFlag, bool, bool*) + 2232 3 CoreText 0x4edf0 TKerningEngine::PositionGlyphs(TRunGlue&, TCharStream const&, signed char) + 1108 4 CoreText 0x4eee8 TTypesetter::FinishLayout(std::__1::tuple<TLine const*, TCharStream const*, void const* ()(__CTRun const, __CFString const*, void*), void*, std::__1::shared_ptr, unsigned int, unsigned char, bool, long> const&, TRunGlue&, signed char, SyncState) + 64 5 CoreText 0x34608 TTypesetterAttrString::Initialize(__CFAttributedString const*, bool) + 3300 6 CoreText 0x34d88 TTypesetterAttrString::TTypesetterAttrString(__CFAttributedString const*, __CFDictionary const*, bool) + 160 7 CoreText 0x34c38 CTLineCreateWithAttributedString + 84 8 UIFoundation 0x6204 __NSCoreTypesetterCreateBaseLineFromAttributedString + 704 9 UIFoundation 0xafd38 -[NSCoreTypesetter _stringDrawingCoreTextEngineWithOriginalString:rect:padding:graphicsContext:forceClipping:attributes:stringDrawingOptions:drawingContext:stringDrawingInterface:] + 2652 10 UIFoundation 0x26bc __NSStringDrawingEngine + 1592 11 UIFoundation 0xab308 -[NSString(NSExtendedStringDrawing) boundingRectWithSize:options:attributes:context:] + 164 12 UIKitCore 0x186a978 + 132 13 UIKitCore 0x48a7c + 668 14 UIKitCore 0x186b35c + 444 15 UIKitCore 0x186eb30 + 408 16 UIKitCore 0x486d4 + 136 17 UIKitCore 0x47c1c + 80 18 UIKitCore 0x1b68e4 + 80 19 UIKitCore 0x1867c08 + 760 20 UIKitCore 0x18678ec + 72 21 UIKitCore 0x186be30 + 104 ....... 28 UIKitCore 0xa894e0 + 52 29 UIKitCore 0x19047fc + 76 30 UIKitCore 0xa88b0c + 1196 31 UIKitCore 0xa91ce0 + 524 32 UIKitCore 0xa9222c + 280 33 UIKitCore 0xa90550 + 3036 34 UIKitCore 0x1e1604 + 280 35 UIKitCore 0x27078 + 912 36 UIKitCore 0x27b38 + 40 37 UIKitCore 0x190df68 + 2532 38 QuartzCore 0xac8bc + 116 39 QuartzCore 0x8f2fc + 600 40 QuartzCore 0xadf84 + 200 41 QuartzCore 0x6ef78 + 536 42 QuartzCore 0x9bab0 + 644 43 QuartzCore 0xa93c0 + 88 44 UIKitCore 0x780f0 + 52 45 UIKitCore 0x78024 + 352 46 UIKitCore 0x85ee8 + 128 47 UIKitCore 0x85378 + 60 48 UpdateCycle 0x15f8 UC::DriverCore::continueProcessing() + 84 49 CoreFoundation 0x6a230 + 28 50 CoreFoundation 0x6a1a4 + 172 51 CoreFoundation 0x47c6c + 232 52 CoreFoundation 0x1d8b0 + 820 53 CoreFoundation 0x1cc44 + 532 54 GraphicsServices 0x1498 GSEventRunModal + 120 55 UIKitCore 0xa9ddc + 792 56 UIKitCore 0x4eb0c UIApplicationMain + 336 57 UIKitCore 0x18a860 + 588 59 ??? 0x18c7cae28 (缺少)
2
0
464
Sep ’25
How to intercept or prevent user input in SwiftUI TextField when embedding in UIKit
Hi all, I’m working on a UIKit app where I embed a SwiftUI TextField using UIHostingController. I’m using an ObservableObject model to drive the textfield content: class TextFieldModel: ObservableObject { @Published var text: String @Published var placeholder: String @Published var isSecure: Bool @Published var isFocused: Bool init(pText: String, pPlaceholder: String, pIsSecure: Bool, pIsFocused: Bool) { self.text = pText self.placeholder = pPlaceholder self.isSecure = pIsSecure self.isFocused = pIsFocused } } And my SwiftUI view: struct TextFieldUI: View { @ObservedObject var pModel: TextFieldModel @FocusState private var pIsFocusedState: Bool var body: some View { TextField(pModel.placeholder, text: $pModel.text) .focused($pIsFocusedState) } } I embed it in UIKit like this: let swiftUIContentView = TextFieldUI(pModel: model) let hostingController = UIHostingController(rootView: swiftUIContentView) addChild(hostingController) view.addSubview(hostingController.view) hostingController.didMove(toParent: self) Question: In UIKit, if I subclass UITextField, I can override insertText(_:) and choose not to call super, effectively preventing the textfield from updating when the user types. Is there a SwiftUI equivalent to intercept and optionally prevent user input in a TextField, especially when it’s embedded inside UIKit? What is the recommended approach in SwiftUI for this?
0
0
75
Sep ’25