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

iPadOS keyboard formatting options
Hi, When I have a UITextView displayed on screen and in focus, the iPad keyboard shows buttons to Bold, Italics and Underline text (since it supports attributed text), and also a 'formatting' button that allows the user to change the font, color and size of the text, as well as justify text and add numbered lists and bullet points. Is there any way to disable or remove this 'formatting' button? My app doesn't support saving these options (other than bold, italics and underline), so it confuses users to see this option. Thanks.
Topic: UI Frameworks SubTopic: UIKit
0
0
102
4d
Wrong tint on CPMapButton in iOS 26
In my CarPlay app my CPMapButton with system images have the wrong tint when the CarPlay appearance is set to "Always Dark". Here is what it looks like. When I change the system appearance to "Automatic" the buttons look fine. Has anyone encountered this or know how to fix it?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
83
4d
How to access launchOptions in SceneDelegate?
Previously, when using AppDelegate, I was able to check the app’s launch options (launchOptions) to determine cases such as: Location updates (UIApplication.LaunchOptionsKey.location) Background push notifications (UIApplication.LaunchOptionsKey.remoteNotification) However, after migrating to the SceneDelegate approach, launchOptions is no longer available — it always returns nil. In my app, I need to branch the code depending on the launch options, but I can’t find a way to achieve this in the SceneDelegate environment. 👉 Is there a way to access launch options in SceneDelegate, similar to how it worked in AppDelegate? Or, if that’s no longer possible, what would be the proper alternative approach? Any guidance would be greatly appreciated.
2
0
96
4d
UIRequiresFullScreen Deprecation
I work on a universal app that targets both iPhone and iPad. Our iPad app currently requires full screen. When testing on the latest iPadOS 26 beta, we see the following warning printed to the console: Update the Info.plist: 1) `UIRequiresFullScreen` will soon be ignored. 2) Support for all orientations will soon be required. It will take a fair amount of effort to update our app to properly support presentation in a resizable window. We wanted to gauge how urgent this change is. Our testing has shown that iPadOS 26 supports our app in a non-resizable window. Can someone from Apple provide any guidance as to how soon “soon” is? Will UIRequiresFullScreen be ignored in iPadOS 26? Will support for all orientations be required in iPadOS 26?
5
2
306
4d
Navigation title not visible in SplitViewController in macCatalyst on iOS 26
We are using a column style split view controller as root view of our app and in iOS26 the navigation titles of primary and supplementary view controllers are not visible and secondary view controller title is displayed in supplementary column. Looks the split view hidden all the child view controllers title and shown the secondary view title as global in macCatlayst. The right and left barbutton items are showing properly for individual view controllers. Facing this weird issue in iOS26 betas. The secondary navigation title also visible only when WindowScene,titlebar.titleVisibility is not hidden. Kindly suggest the fix for this issue as we can't use the secondary view navigation title for showing supplementary view's data. The issue not arises in old style split views or when the split view embedded in another splitView. Refer the sample code and attachment here let splitView = UISplitViewController(style: .tripleColumn) splitView.preferredDisplayMode = .twoBesideSecondary splitView.setViewController(SplitViewChildVc(title: "Primary"), for: .primary) splitView.setViewController(SplitViewChildVc(title: "Supplementary"), for: .supplementary) splitView.setViewController(SplitViewChildVc(title: "Secondary"), for: .secondary) class SplitViewChildVc: UIViewController { let viewTitle: String init(title: String = "Default") { self.viewTitle = title super.init(nibName: nil, bundle: nil) } override func viewDidLoad() { super.viewDidLoad() self.title = viewTitle self.navigationItem.title = viewTitle if #available(iOS 26.0, *) { navigationItem.subtitle = "Subtitle" } let leftbutton = UIBarButtonItem(barButtonSystemItem: .cancel, target: nil, action: nil) navigationItem.leftBarButtonItem = leftbutton let rightbutton = UIBarButtonItem(barButtonSystemItem: .add, target: nil, action: nil) navigationItem.rightBarButtonItem = rightbutton } }
0
0
174
5d
UIBarButtonItem Doesn't Reset the Badge
Hello, I hope you're all doing well! I'm currently working on integrating new iOS 26 features into my app, and so far, the process has been really exciting. However, I've encountered an issue when updating the badge of a UIBarButtonItem, and I’m hoping to get some insights or suggestions. The app has two UIViewController instances in the navigation stack, each containing a UIBarButtonItem. On the first controller, the badge is set to 1, and on the second, the badge is set to 2. In the second controller, there is a "Reset" button that sets the badge of the second controller to nil. However, when I tap the "Reset" button, instead of setting the badge to nil, it sets the value to 1. I would appreciate any ideas or suggestions on how to solve this problem. Maybe I am using the badge API incorrectly. Thank you! class ViewController: UIViewController { var cartButtonItem: UIBarButtonItem! override func viewDidLoad() { super.viewDidLoad() configureNavigationItem() } func configureNavigationItem() { cartButtonItem = UIBarButtonItem(image: UIImage(resource: .cartNavBar), style: .plain, target: self, action: #selector(showCartTab)) cartButtonItem.tintColor = UIColor.systemBlue cartButtonItem.badge = .count(1) navigationItem.rightBarButtonItem = cartButtonItem } @objc func showCartTab() { // Add second view controller in navigation stack performSegue(withIdentifier: "Cart", sender: nil) } } class CartViewController: UIViewController { var cartButtonItem: UIBarButtonItem! override func viewDidLoad() { super.viewDidLoad() configureNavigationItem() } func configureNavigationItem() { cartButtonItem = UIBarButtonItem(image: UIImage(resource: .cartNavBar), style: .plain, target: nil, action: nil) cartButtonItem.tintColor = UIColor.systemBlue cartButtonItem.badge = .count(2) navigationItem.rightBarButtonItem = cartButtonItem } func updateBadge() { cartButtonItem.badge = nil } @IBAction func resetButtonPressed(_ sender: Any) { updateBadge() } }
0
0
62
5d
[NSBitmapImageRep imageRepsWithContentsOfFile] error with HDR
[NSBitmapImageRep imageRepsWithContentsOfFile] is returning empty/solid black bitmaps for some image files with HDR on macOS Tahoe beta. I opened an Apple feedback report but curious if anyone else is seeing this. Errors thrown in the debugger are: IIOApplyHDRGainMap:351: FlexGTC headroom (4.0) doesn't match target headroom (1.0) +[HDRImage getGainMapVersionMajor:minor:fromMetadata:]:417: Failed to get metadata tag: HDRGainMap:HDRGainMapVersion +[HDRImage getGainMapHeadroom:fromMetadata:]:443: Failed to read gain map version info: <CGImageMetadata 0x9fc013700> ( iio:hasXMP = True ) This function call has worked reliable for many years before the Tahoe beta.
Topic: UI Frameworks SubTopic: UIKit
3
0
114
6d
App Crashes on Paper Selection After Background Printer Connection
Description: 1. When initiating the print flow via UIPrintInteractionController, and no printer is initially connected, iOS displays all possible paper sizes in the paper selection UI. However, if a printer connects in the background after this view is shown, the list of paper sizes does not automatically refresh to reflect only the options supported by the connected printer. 2. If the user selects an incompatible paper size (one not supported by the printer that has just connected), the app crashes due to an invalid configuration. Steps to Reproduce: Launch the app and navigate to the print functionality. Tap the Print button to invoke UIPrintInteractionController. At this point, no printer is yet connected. iOS displays all available paper sizes. While the paper selection UI is visible, the AirPrint-compatible printer connects in the background. Without dismissing the controller, the user selects a paper size (e.g., one that is not supported by the printer). The app crashes. Expected Result: App should not crash Once the printer becomes available (connected in the background), the paper size options should refresh automatically. The list should be filtered to only include sizes that are compatible with the connected printer. This prevents the user from selecting an invalid option, avoiding crashes. Actual Result: App crashes The paper size list remains unfiltered. The user can still select unsupported paper sizes. Selecting an incompatible option causes the app to crash, due to a mismatch between UI selection and printer capability. Demo App Crash : https://drive.google.com/file/d/19PV02wzOJhc2DYI6kAe-uxHuR1Qg15Bu/view?usp=sharing Apple Files App Crash: https://drive.google.com/file/d/1flHKuU_xaxHSzRun1dYlh8w7nBPJZeRb/view?usp=sharing
1
0
51
1w
Clarification on the purpose of return value in textFieldShouldReturn
I’m trying to understand the exact role of the return value in the UITextFieldDelegate method textFieldShouldReturn(_:). From my experiments in Xcode, I observed: Returning true vs false does not seem to cause any visible difference (e.g., the keyboard does not automatically dismiss either way). I know that in shouldChangeCharactersIn returning true allows the system to insert the character, and returning false prevents it. That’s clear. For textFieldShouldReturn, my current understanding is that returning true means “let the OS handle the Return press,” and returning false means “I’ll handle it myself.” My confusion: what is it that the OS actually does when it “handles” the Return press? Does UIKit do anything beyond calling this delegate method? If the system is supposed to dismiss the keyboard when returning true, why doesn’t it happen automatically? I’d appreciate clarification on the expected use of this return value — specifically, what default behavior the system performs (if any) when we return true. Thanks!
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
70
1w
EXC_BAD_ACCESS (SIGSEGV) crash observed in NSDateFormatter APIs
(NSString*)getClienttime { NSDate* currentDate = [NSDate date]; NSDateFormatter* dateformatter = [[NSDateFormatter alloc] init]; dateformatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8*3600]; dateformatter.locale= [NSLocale systemLocale]; [dateformatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; return [dateformatter stringFromDate:currentDate]?:@""; } the info of crash 1 libicucore.A.dylib icu::UnicodeString::copyFrom(icu::UnicodeString const&, signed char) (in libicucore.A.dylib) + 36 2 libicucore.A.dylib icu::DecimalFormatSymbols::operator=(icu::DecimalFormatSymbols const&) (in libicucore.A.dylib) + 64 3 libicucore.A.dylib icu::DecimalFormatSymbols::operator=(icu::DecimalFormatSymbols const&) (in libicucore.A.dylib) + 64 4 libicucore.A.dylib icu::DecimalFormat::DecimalFormat(icu::DecimalFormat const&) (in libicucore.A.dylib) + 188 5 libicucore.A.dylib icu::DecimalFormat::clone() const (in libicucore.A.dylib) + 48 6 libicucore.A.dylib icu::NumberFormat::createInstance(icu::Locale const&, UNumberFormatStyle, UErrorCode&) (in libicucore.A.dylib) + 188 7 libicucore.A.dylib icu::SimpleDateFormat::initialize(icu::Locale const&, UErrorCode&) (in libicucore.A.dylib) + 580 8 libicucore.A.dylib icu::SimpleDateFormat::SimpleDateFormat(icu::Locale const&, UErrorCode&) (in libicucore.A.dylib) + 332 9 libicucore.A.dylib icu::DateFormat::create(icu::DateFormat::EStyle, icu::DateFormat::EStyle, icu::Locale const&) (in libicucore.A.dylib) + 264 10 libicucore.A.dylib udat_open (in libicucore.A.dylib) + 396 11 CoreFoundation __cficu_udat_open (in CoreFoundation) + 72 12 CoreFoundation __ResetUDateFormat (in CoreFoundation) + 508 13 CoreFoundation __CreateCFDateFormatter (in CoreFoundation) + 324 14 Foundation -[NSDateFormatter _regenerateFormatter] (in Foundation) + 204 15 Foundation -[NSDateFormatter stringForObjectValue:] (in Foundation) + 104 16 ABC +[JMAContext getClienttime] (in DadaStaff) (JMAContext.m:73)
Topic: UI Frameworks SubTopic: UIKit
0
0
87
1w
Issue with iOS26 and hiding UITabBar
I have a strange issue for iOS26. I have a UITabBarController at the root view of the app, but on certain actions, I want to hide it temporarily, and then have some options where the user can press a button which display some options using UIAlertController. It used to work fine before, but with iOS26, when the UIAlertController is presented, the tab bar (which is hidden by setting the ‘frame’) suddenly pops back into view automatically, when I don't want it to. Here's an example that reproduces the issue: class TestTableViewController: UITableViewController { private var isEditMode: Bool = false override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Change", style: .plain, target: self, action: #selector(changeMode)) } @objc func changeMode() { print("change mode called") if isEditMode == false { isEditMode = true // hide tab bar setEditingBarVisible(true, animated: true) self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Action", style: .plain, target: self, action: #selector(showActionsList)) } else { isEditMode = false // show tab bar setEditingBarVisible(false, animated: true) self.navigationItem.rightBarButtonItem = nil } } @objc func showActionsList() { let alert = UIAlertController(title: "Action", message: "showing message", preferredStyle: .actionSheet) alert.addAction(UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil)) self.present(alert, animated: true, completion: nil) } @objc func setEditingBarVisible(_ visible: Bool, animated: Bool) { guard let tabBar = tabBarController?.tabBar else { return } let performChanges = { // Slide the tab bar off/on screen by adjusting its frame’s y. // This is safe because UITabBar is frame-managed, not Auto Layout constrained. var frame = tabBar.frame let height = frame.size.height if visible { // push it down if not already if frame.origin.y < self.view.bounds.height { frame.origin.y = self.view.bounds.height + self.view.safeAreaInsets.bottom } // Give our content its full height back (remove bottom safe-area padding that tab bar created) self.additionalSafeAreaInsets.bottom = 0 } else { // bring it back to its normal spot frame.origin.y = self.view.bounds.height - height // Re-apply bottom safe-area so content clears the tab bar again self.additionalSafeAreaInsets.bottom = height } tabBar.frame = frame // Ensure layout updates during animation self.tabBarController?.view.layoutIfNeeded() self.view.layoutIfNeeded() } if animated { UIView.animate(withDuration: 0.28, delay: 0, options: [.curveEaseInOut]) { performChanges() } } else { performChanges() } } } I have a bar button called 'Change', and selecting it should hide/show the UITabBar at the bottom, and show/hide a different bar button called 'Action'. Selecting the 'Action' button shows an alert. With iOS26, with the tab bar moved out of view, when the 'Action' button is called, the alert shows but the tab bar automatically moves into view as well. Is this a known issue? Any workaround for it? I filed FB19954757 just in case.
Topic: UI Frameworks SubTopic: UIKit
0
0
124
1w
No large titles margin on iOS 26
I need more time to adapt to the new iOS 26 UI, so I set the "UIDesignRequiresCompatibility" attribute to "Yes." This works, but now all large titles are not aligned with the content. Below you can see an example, but I have the issue with all large titles. All good on iOS 18. Does anyone have an idea why and how can i fix it?
2
1
126
1w
Floating keyboard issues on iPadOS 26
Observed on iPadOS 26 b8 in apps built with current SDK: Floating keyboard lacks corner mask Floating key blue highlight not aligned with its background Invoking floating keyboard can result in “ghost” full-sized keyboard appearing at bottom of screen Swipe-dismissing floating keyboard can result in it bouncing back up, again with ghost keyboard appearing Touching globe key can produce menus truncated/obscured by ghost keyboard Ghost keyboard can remain visible even after backgrounding the app (Some of these issues may be limited to non-English keyboards) FB19951605
Topic: UI Frameworks SubTopic: UIKit
0
0
125
1w
TextKit 2 calls NSTextLayoutFragment's draw method too often
The following is verbatim of a feedback report (FB19809442) I submitted, shared here as someone else might be interested to see it (I hate the fact that we can't see each other's feedbacks). On iOS 16, TextKit 2 calls NSTextLayoutFragment's draw(at:in:) method once for the first paragraph, but for every other paragraph, it calls it continuously on every scroll step in the UITextView. (The first paragraph is not cached; its draw is called again when it is about to be displayed again, but then it is again called only once per its lifecycle.) On iOS 17, the behavior is similar; the draw method gets called once for the 1st and 2nd paragraph, and for every other paragraph it again gets called continuously as a user scrolls a UITextView. On iOS 18 (and iOS 26 beta 4), TextKit 2 calls the layout fragment's draw(at:in:) on every scroll step in the UITextView, for all paragraphs. This results in terrible performance. TextKit 2 is promised to bring many performance benefits by utilizing the viewport - a new concept that represents the visible area of a text view, along with a small overscroll. However, having the draw method being constantly called almost negates all the performance benefits that viewport brings. Imagine what could happen if someone needs to add just a bit of logic to that draw method. FPS drops significantly and UX is terribly degraded. I tried optimizing this by only rendering those text line fragments which are in the viewport, by using NSTextViewportLayoutController.viewportBounds and converting NSTextLineFragment.typographicBounds to the viewport-relative coordinate space (i.e. the coordinate space of the UITextView itself). However, this patch only works on iOS 18 where the draw method is called too many times, as the viewport changes. (I may have some other problems in my implementation, but I gave up on improving those, as this can't work reliably on all OS versions since the underlying framework isn't calling the method consistently.) Is this expected? What are our options for improving performance in these areas?
6
0
143
1w
UITabBarController not allowing scroll content behind it
I am trying out iOS26 with my existing app. I have a UITabBarController which is set to the main window's rootViewController, and I setup my UITabBar viewControllers programmatically. The first tab's root view has a UITableView with 100s of rows. When I build and run with the new Xcode, the app has the iOS26 look, but the table view doesn't seem to scroll behind the tab bar. The tab bar seems to have a hard edge and the content doesn't show through behind that. I have tried setting up the UITabBarController with the UITab items from iOS18 as well, but that doesn't help either. If I build a new project using the Xcode template, with storyboards, it works as expected and table view content shows through the UITabBar. What could be causing this? Is there something I need to configure to get the correct effect in iOS26? -- Figure it out: I needed to pin the bottomAnchor of the view controller to view's bottomAnchor (not safeAreaLayoutGuide.bottomAnchor)
Topic: UI Frameworks SubTopic: UIKit
0
0
160
1w
iOS 26 beta3 Custom keyboard always displays a gray bar above it
Problem description: When using the Custom keyboard in various system application scenarios, a gray area is always displayed at the top of the Custom keyboard. Although the system has been restarted and the Custom keyboard has been restarted, and the pull-down operation has been repeated in multiple system application environments, the gray bar still appears. This problem also has the same problem on other input method software. Reproduction steps: Set the current input method to "CustomKeybaord" In the memo app or any other system app, pull up the Custom keyboard, or switch to the Custom keyboard. Observe whether a gray area is always displayed above the Custom keyboard. Request: I would like to understand whether the current behavior is a bug or if it requires Custom keyboards to adapt their style accordingly. However, I not found that currently unable to modify the style or color of the gray bar in question, and I do not have a suitable adaptation solution at this time. I would appreciate further assistance
Topic: UI Frameworks SubTopic: UIKit
4
1
197
1w
Setting Tint Color for Prominent Style UIBarButtonItems at App Level in iOS26
In iOS 26, with the introduction of the new prominent style buttons like system done, how to apply the tint color for these buttons in globally at app level. We are only able to set for individual buttons using barButtonItem.tintColor and need a way to apply globally. We’ve tried: UIBarButtonItem.appearance().tintColor UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationController.self]).tintColor but nothing worked. sample code: let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: nil) doneButton.tintColor = .systemPink Is there a new recommended way to globally style UIBarButtonItem with the prominent style in iOS 26?
Topic: UI Frameworks SubTopic: UIKit Tags:
15
1
362
1w
Can we use a class (.self) as the target in addTarget(_:action:for:) for static event handlers?
I am building a centralized event handling system for UIKit controls and gesture recognizers. My current approach registers events using static methods inside a handler class, like this: internal class TWOSInternalCommonEventKerneliOS { internal static func RegisterTouchUpInside(_ pWidget: UIControl) -> Void { pWidget.addTarget( TWOSInternalCommonEventKerneliOS.self, action: #selector(TWOSInternalCommonEventKerneliOS.WidgetTouchUpInsideListener(_:)), for: .touchUpInside ) } @objc internal static func WidgetTouchUpInsideListener(_ pWidget: UIView) -> Void { print("WidgetTouchUpInside") } } This works in my testing because the methods are marked @objc and static, but I couldn’t find Apple documentation explicitly confirming whether using ClassName.self (instead of an object instance) is officially supported. Questions: Is this approach (passing ClassName.self as the target) recommended or officially supported by UIKit? If not, what is the safer alternative to achieve a similar pattern, where event registration can remain in static methods but still follow UIKit conventions? Would using a shared singleton instance as the target (e.g., TWOSInternalCommonEventKerneliOS.shared) be the correct approach, or is there a better pattern? Looking for official guidance to avoid undefined behavior in production.
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
59
1w