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

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
85
1w
iOS26 UISearchbar and UISearchController cancellation issues
Is the Cancel button intentionally removed from UISearchBar (right side)? Even when using searchController with navigationItem also. showsCancelButton = true doesn’t display the cancel button. Also: When tapping the clear ("x") button inside the search field, the search is getting canceled, and searchBarCancelButtonClicked(_:) is triggered (Generally it should only clear text, not cancel search). If the search text is empty and I tap outside the search bar, the search is canceled. Also when I have tableview in my controller(like recent searches) below search bar and if I try to tap when editing started, action is not triggered(verified in sample too). Just cancellation is happening. In a split view controller, if the search is on the right side and I try to open the side panel, the search also gets canceled. Are these behaviors intentional changes, beta issues, or are we missing something in implementation?
5
0
201
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
71
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
127
1w
[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
115
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
126
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
162
1w
UICollectionView list: leading swipe overshoots in expanded split view for .plain/.grouped; .insetGrouped OK (iPadOS 26 b5–b8) [FB19785883]
Hi all, Sharing a reproducible UIKit issue I’m seeing across multiple iPadOS 26 betas, with a tiny sample attached and a short video. Short video https://youtu.be/QekYNnHsfYk Tiny project https://github.com/yoasha/ListSwipeOvershootReproSwift Summary In a UISplitViewController (.doubleColumn), a UICollectionView using list layout shows a large leading-swipe overshoot when the split view is expanded (isCollapsed == false). The cell content translates roughly 3–4× the action width. Repros with appearance = .plain and .grouped Does not repro with .insetGrouped Independent of trailing provider (issue persists when trailing provider is nil) Collapsed split (compact width) behaves correctly Environment Devices: iPad Air (3rd gen), iPadOS 26.0 (23A5326a) → Repro Simulators: iPad Pro 11-inch (M4), iPadOS 26.0 beta 6 → Repro Also tested on device: iPadOS 26 beta 5, 6, 7, 8 Xcode: 26.0 beta 6 (17A5305f) Steps to reproduce Launch the sample; ensure the split is expanded (isCollapsed == false). In the secondary list, set Appearance = Plain (also repros with Grouped). Perform a leading swipe (LTR: swipe right) on any row. Actual: content shifts ~3–4× the action width (overshoot). Expected: content translates exactly the action width. Switch Appearance = InsetGrouped and repeat the leading (swipe right) gesture → correct (no overshoot). Feedback Assistant FB ID: FB19785883 (full report + attachments filed; this forum thread mirrors the repro for wider visibility) Minimal code (core of the sample) If anyone from Apple needs additional traces or a sysdiagnose, I can attach promptly. Thanks! // Secondary column VC (snippet) var cfg = UICollectionLayoutListConfiguration(appearance: .plain) // also .grouped / .insetGrouped cfg.showsSeparators = true cfg.headerMode = .none cfg.leadingSwipeActionsConfigurationProvider = { _ in let read = UIContextualAction(style: .normal, title: "Read") { _,_,done in done(true) } read.backgroundColor = .systemBlue let s = UISwipeActionsConfiguration(actions: [read]) s.performsFirstActionWithFullSwipe = false return s } // Trailing provider can be nil and the bug still repros for leading swipe: cfg.trailingSwipeActionsConfigurationProvider = nil let layout = UICollectionViewCompositionalLayout.list(using: cfg) let collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout) // … standard data source with UICollectionViewListCell + UIListContentConfiguration // Split setup (snippet) let split = UISplitViewController(style: .doubleColumn) split.preferredDisplayMode = .oneBesideSecondary split.viewControllers = [ UINavigationController(rootViewController: PrimaryTableViewController()), UINavigationController(rootViewController: SecondaryListViewController()) ]
0
0
94
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
130
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
60
1w
Issue with custom keyboard height when toggle inputView in iOS 26 beta.
Issue Description: When toggling between the system keyboard and a custom input view, the keyboard height reported in subsequent keyboard notifications becomes incorrect!!! specifically missing the predictive text/suggestion bar height. Environment: Device: iPhone 11 Expected keyboard height: 346pt Actual reported height: 301pt (missing 45pt suggestion bar) Reproduction Steps: Present system keyboard → Height correctly reported as 346pt Switch to custom input view → Custom view displayed Switch back to system keyboard(no suggestion bar) → Height correctly reported as 301pt Trigger keyboard frame change → Height still incorrectly reported as 301pt despite suggestion bar being visible Expected Behavior: Keyboard height should consistently include the suggestion bar height (346pt total). Actual Behavior: After switching from custom input view, keyboard height excludes suggestion bar height (301pt instead of 346pt). key code private func bindEvents() { customTextField.toggleInputViewSubject.sink { [weak self] isShowingCustomInput in guard let strongSelf = self else { return } if isShowingCustomInput { strongSelf.customTextField.inputView = strongSelf.customInputView strongSelf.customInputView.frame = CGRect(x: 0, y: 0, width: strongSelf.view.frame.size.width, height: strongSelf.storedKeyboardHeight) } else { strongSelf.cusTextField.inputView = nil } strongSelf.customTextField.reloadInputViews() strongSelf.customTextField.becomeFirstResponder() }.store(in: &cancellables) }
Topic: UI Frameworks SubTopic: UIKit Tags:
0
1
94
2w
UICollectionView Drag to edge of screen is not working with Stage Manager
In our app we have a UICollectionView with Drag&Drop functionality enable and collection view is covering the entire screen. When we drag a collection view item to the edge of the screen it does not scroll the UICollectionView instead that our item turns into the app icon and scrolling blocked. It is happening only if Stage Manager is enabled in the device and if Stage Manager is disabled it is working fine. This issue we are facing after iOS 18.6 release, before 18.6 it was working fine i.e, collection view was scrolling to next items when we dragging an item to edge of the screen, similar to the iOS calendar app when we drag an event to edge it starts scrolling the date. And in iOS 26 if we drag an item to edge, Springboard is getting crashed.
1
1
101
2w
UIGraphicsImageRenderer display blank image with iOS 26
Hello, First of all, I've already made a bug report here : https://feedbackassistant.apple.com/feedback/19731998 I'm facing a problem while using UIGraphicsImageRenderer to create an image, that is use to create a UIColor with a pattern via UIColor(patternImage:). It's well displayed for iOS 18.2 and lower, whereas the whole color is blank with iOS 26. -> Please find a sample project linked to the bug report ViewController.swift post that illustrates the issue, in the ViewController.swift file. I'll also link screenshots of the sample app, one built with iOS 18.2 and another with iOS 26.0. Reproduction steps : I create an image with UIGraphicsImageRenderer : let image = UIGraphicsImageRenderer().image { context in // Do anything here } Then I use this image to create a UIColor : UIColor(patternImage: image) I apply this color to the fillColor of a CAShapeLayer : shapeLayer.fillColor = UIColor(patternImage: image) Expected result : Run on iOS 26 and lower and the layer filled with the pattern color is correctly displayed, as it is on iOS 18.2 and lower. Observed result : Run on iOS 26 and the layer is filled with a blank/white color instead of the intended pattern color. Has anyone been facing the problem ? Thanks, Thibault Poujat
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
54
2w
Change to safe area logic on iOS 26
I have a few view controllers in a large UIKit application that previously started showing content right below the bottom of the top navigation toolbar. When testing the same code on iOS 26, these same views have their content extend under the navigation bar and toolbar. I was able to fix it with: if #available(iOS 26, *, *) { self.edgesForExtendedLayout = [.bottom] } when running on iOS 26. I also fixed one or two places where the main view was anchored to self.view.topAnchor instead of self.view.safeAreaLayoutGuide.topAnchor. Although this seems to work, I wonder if this was an intended change in iOS 26 or just a temporary bug in the beta that will be resolved. Were changes made to the safe area and edgesForExtendedLayout logic in iOS 26? If so, is there a place I can see what the specific changes were, so I know my code is handling it properly? Thanks!
Topic: UI Frameworks SubTopic: UIKit
3
2
300
2w
iOS 26 (beta) Nav Bar Item Image Insets bug
I've noticed that in iOS 26, Navigation Bar Items' Image Insets parameters as set in Xcode are not being read correctly. Specifically, it appears that on iOS 26 beta, negative inset numbers are being read as positive. Feedback report FB19838333 includes a sample project demonstrating this bug.
0
0
131
2w
Compositional Layout's broken `visibleItemsInvalidationHandler`
Hello everybody! TLDR: Issues with visibleItemsInvalidationHandler. Minimal code to reproduce available. I've been working with Compositional Layout for a while now and recently I've found myself needing to implement custom animation based on scroll position of UI elements. Once I found visibleItemsInvalidationHandler it felt like the exact solution that I needed. Once I implement I've found out it doesn't quite behave as you'd expect. To put it simply, it seems like the animations only work if your whole layout does not use .estimated nor .uniformAcrossSiblings. As soon as you use them then the animations will stop working, I've debugged it deeper and it seems like the invalidation context generated by it does not include the indexPath of the cells, which is always included in the version in which it works. Feel free to swap the line 51 with its comment to flip between the working and failing version of it. Playground Example My final question therefore is... Is this the expected behavior? The documentation doesn't give any clues about such behavior and although I've tried relentlessly to find a workaround for this specific hiccup I was not successful with it.
1
0
99
2w
Issue with custom keyboard height when rotating from landscape to portrait in iOS 26 beta.
When using a custom keyboard set via UIResponder.inputView, a gap appears between the text field and the custom keyboard after rotating from portrait to landscape and back to portrait. On a portrait screen, when switching to a custom keyboard: The input field at the top and the custom keyboard below it appear normally, with no empty space in between. When I rotate from portrait to landscape, a gap appears in the middle.
Topic: UI Frameworks SubTopic: UIKit
1
1
84
2w
WKWebView LoadRequest crash on ios 26
Since the ios 26 beta our app is crashing when calling LoadRequest() on the wkwebview class. The app crashes out completely when it occurs even in the debugger, I was able to get a stack trace from our Sentry crash handler. See below It seems that calling LoadRequest from the mainthread fixes the issue but I don't understand why, theres no documentation to suggest this must be done. Any ideas? Below is the stack trace I got from Sentry: WebKit +0x0054e00 WebKit::allDataStores WebKit +0x0bf34f4 WebKit::NetworkProcessProxy::preconnectTo WebKit +0x0acef64 WebKit::WebPageProxy::preconnectTo WebKit +0x0b0d92c WTF::Detail::CallableWrapper::call WebKit +0x0ab6cf8 WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle WebKit +0x0ab84dc WebKit::WebPageProxy::loadRequestWithNavigationShared WebKit +0x0ab7adc WebKit::WebPageProxy::loadRequest WebKit +0x05d0704 -[WKWebView loadRequest:] Grid3iOS +0x5240944 xamarin_dyn_objc_msgSendSuper In App Grid3iOS +0x187dec4 wrapper_managed_to_native_ObjCRuntime_Messaging_NativeHandle_objc_msgSendSuper_NativeHandle_intptr_intptr_ObjCRuntime_NativeHandle In App Grid3iOS +0x512fac4 Microsoft_iOS_WebKit_WKWebView_LoadRequest_Foundation_NSUrlRequest (WKWebView.g.cs:572)
1
0
51
2w
UIGlassEffect can leave an unusual grey shadow around the view
When adding a glass effect to my UIControl: let effectView = UIVisualEffectView() let glassEffect = UIGlassEffect() glassEffect.isInteractive = true effectView.effect = glassEffect effectView.cornerConfiguration = .capsule() addSubview(effectView) effectView.snp.makeConstraints { $0.edges.equalToSuperview() } effectView.contentView.addSubview(stackView) for subview in effectView.subviews { subview.backgroundColor = .clear } self.effectView = effectView I find that I get this visual effect: These controls are the only view within a UICollectionViewCell. Nothing in the hierarchy of the collectionview to the control has a background color. The grey background only seems to appear when I place the glass effect. Without the glass effect, there is no grey shading.
Topic: UI Frameworks SubTopic: UIKit
3
0
147
2w