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

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
93
Jul ’25
Large title is not visible in iOS 26
I am using below code to change navigationBar bg colour, but the text is hidden in large title. It works fine in previous versions. Kindly refer below code and attached images. Code: override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) navigationController?.navigationBar.prefersLargeTitles = true navigationItem.largeTitleDisplayMode = .always let appearance = UINavigationBarAppearance() appearance.backgroundColor = UIColor( red: 0.101961, green: 0.439216, blue: 0.388235, alpha: 1.0 ) navigationController?.navigationBar.standardAppearance = appearance navigationController?.navigationBar.scrollEdgeAppearance = appearance navigationController?.navigationBar.compactAppearance = appearance } Referenced images:
2
2
196
Jul ’25
Positioning an image
This may seem really basic, but I'm not using the screen designer, I'm doing this old school (programmatically). I think I'm using Swift 5 (not actually sure). This image may help. So I created my own UIImageView class called GenericImage class GenericImage: UIImageView, @unchecked Sendable { ... } I create the GenericImage class and add it to the View Controller. Then I load the image and set some positioning within my GenericImage class let imageView = GenericImage(frame: CGRect.zero) self.view.addSubview(imageView) imageView.processResponse(componentDictionary ) In the GenericImage class I load the image and set some constraints. self.imageFromURL(urlString: imageUrl) self.translatesAutoresizingMaskIntoConstraints = false self.contentMode = .scaleAspectFit self.widthAnchor.constraint(equalToConstant: 100.0).isActive = true self.heightAnchor.constraint(equalToConstant: 100.0).isActive = true self.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true self.topAnchor.constraint(equalTo: self.centerYAnchor).isActive = true The image is displayed at the top left of the screen. I'm guessing that the code I have written should center the image on the screen. However, while I would like to know how to center the image, I also want to be able to position it at a specific place on the screen, using points (or pixels). Any suggestions?
3
0
120
Jul ’25
UIKit crash on app built with Xcode 26 but run on iOS 18.X
An app built on Xcode 26 (beta4) presents various UIViewCOntrollers. Presentation of any UIViewController that contains a UIToolbar leads to a UIKit crash when run on an iOS 18.5 device, it does not crash when run on iOS 26. The exception logged: *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named TtGC5UIKit17UICoreHostingViewVCS_21ToolbarVisualProvider8RootView because no class named TtGC5UIKit17UICoreHostingViewVCS_21ToolbarVisualProvider8RootView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)' Anyone else seen this? I've submitted a bug report via Feedback Assistant, including a minimal Xcode workspace that reproduces the crash, hoping this will get some attention.
13
3
444
Jul ’25
Getting two searchBar in iOS 26.0
Hi team, while i am using below code, i am getting two searchBar at top & bottom. Kindly refer below code & attached image Code: override func viewDidLoad() { super.viewDidLoad() title = "Test Data" setupSearchData() DispatchQueue.main.asyncAfter(deadline: .now() + 2) { self.setupSearchData() } } func setupSearchData() { navigationController?.navigationBar.prefersLargeTitles = false let searchController = UISearchController(searchResultsController: nil) navigationItem.searchController = searchController } It is working fine for other iOS versions. In my real useCase, i will refresh screen after API completed, then this issue occurred in my app.
2
0
84
Jul ’25
iOS 26 UISplitViewController in dark mode appearance.
We have encountered a problem on iOS 26. When switching to dark mode, the color of all subviews (font color, background color, etc.) of the Sidebar (Primary View) of UISplitViewController will not change. For example, if it is set to the color of UIColor.label, it will always be black and will not be white in dark mode. On Xcode, just create a UISplitViewController in Storyboard without changing any settings, and run it directly to see the following: The title of the Navigation Bar defaults to the label color, and it is still black after switching to dark mode. There is no such problem in the Secondary View or other places. This problem has occurred since iOS 26 beta 3, and iOS 26 beta 4 is now the same. But beta 1 and beta 2 have no problem. I'm not sure if this is a bug, or if there is something that needs to be changed to adapt to iOS 26?
Topic: UI Frameworks SubTopic: UIKit Tags:
7
4
509
Jul ’25
OS 26 with CNContactViewController issue
when using CNContactViewController to present a contact detail info, the system CNContactViewController appear some UI issues. On iOS 26, the Poster avatar overlaps with the title "Edit device contact" On iPadOS26 with device(not simulator), when click 'Add photo', the CNContactViewController will auto dismiss, and the console output some error log: below are the sample code: AppDelegate.swift: import UIKit @main class AppDelegate: UIResponder, UIApplicationDelegate { let window: UIWindow = UIWindow() func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let vc = SplitViewController(primary: TabBarViewController(), secondary: ViewController()) window.rootViewController = vc window.makeKeyAndVisible() return true } } SplitViewController.swift: import UIKit class SplitViewController: UISplitViewController { init(primary: UIViewController, secondary: UIViewController) { super.init(nibName: nil, bundle: nil) preferredDisplayMode = .oneBesideSecondary presentsWithGesture = false delegate = self viewControllers = [primary, secondary] } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() } } extension SplitViewController: UISplitViewControllerDelegate { } TabBarViewController.swift: import UIKit class BaseViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } } class HomeViewController: BaseViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .red navigationItem.title = "Home" tabBarItem = UITabBarItem(title: "Home", image: UIImage(systemName: "house"), tag: 0) } } class TabBarViewController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() let homeVC = HomeViewController() let homeNav = UINavigationController(rootViewController: homeVC) viewControllers = [homeNav] ContactManager.shared.getAllContactIdentifiers() } } ViewController.swift: import UIKit import Contacts import ContactsUI class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .systemPink let button = UIButton(frame: .zero) button.backgroundColor = .orange button.setTitle("show contact", for: .normal) button.addTarget(self, action: #selector(showContactInfo), for: .touchUpInside) button.translatesAutoresizingMaskIntoConstraints = false view.addSubview(button) button.widthAnchor.constraint(equalToConstant: 200).isActive = true button.heightAnchor.constraint(equalToConstant: 60).isActive = true button.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true button.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true } @objc private func showContactInfo() { print("showContactInfo") let identifier = ContactManager.shared.identifiers[0] let currentContact = try? CNContactStore().unifiedContact(withIdentifier: identifier, keysToFetch: [CNContactViewController.descriptorForRequiredKeys()]) guard let contact: CNMutableContact = currentContact?.mutableCopy() as? CNMutableContact else { return } let vc = CNContactViewController(forNewContact: contact) vc.delegate = self vc.title = "Edit Device Contact" vc.allowsActions = false vc.contactStore = CNContactStore() let navigationVC: UINavigationController = UINavigationController(rootViewController: vc) let appDelegate = UIApplication.shared.delegate as? AppDelegate appDelegate?.window.rootViewController?.present(navigationVC, animated: true, completion: nil) } } extension ViewController: CNContactViewControllerDelegate { public func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) { viewController.dismiss(animated: true, completion: nil) } }
1
0
168
Jul ’25
New iPadOS 26 beta4 crash in `UISplitViewController`
Sample Project In iPadOS 26 beta4, when a UISplitViewController transitions to compact layout and proposes the secondary view controller, a crash occurs: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Layout requested for visible navigation bar, <UINavigationBar: 0x1018205b0; frame = (0 0; 320 54); opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0x600000d37cc0>; layer = <CALayer: 0x600000d13390>> delegate=0x102826600, when the top item belongs to a different navigation bar. topItem = <UINavigationItem: 0x101af3b20> title='Detail' style=navigator rightBarButtonItems=0x600000011e10, navigation bar = <UINavigationBar: 0x101817680; frame = (0 0; 320 54); opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0x600000d12310>; layer = <CALayer: 0x600000d116b0>> delegate=0x102826000, possibly from a client attempt to nest wrapped navigation controllers.' When we show the primary view, there is no crash. Similarly, there is no crash on beta-3. To reproduce the crash in the demo project: Launch the project on an iPad. "Try the Demo" Tap "List-Detail Pattern" To trigger the crash, select any of the list items and switch the app to a compact layout. The crash occurs because the app will attempt to propose the secondary view controller. To avoid the crasah, refrain from selecting an item in the list and switch to the compact layout. The app will not crash because it will attempt to propose the primary view controller.
Topic: UI Frameworks SubTopic: UIKit
1
1
167
Jul ’25
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
374
Jul ’25
The three dots button won't move inside my navigation item group after resizing in iOS 26
I'm working on an old Objective-C project and I'm trying to adapt iOS 26 and liquid glass to current UI. I'm facing an issue that the three dot buttons won't automatically move inside navigation item bar/group after resizing window, instead it displays on top of the navigation left item. App runs entirely on iPad. What I tried: Added Application Scene Manifest to Info.plist Added SceneDelegate and initialized window by windowScene but most old code are still inside AppDelegate class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? let appDelegate = UIApplication.shared.delegate as! TDRAppDelegate func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let scene = (scene as? UIWindowScene) else { return } window = UIWindow(windowScene: scene) window?.isHidden = false appDelegate.window = window appDelegate.initWithWindow() } } - (void)initWithWindow { ... [self initViewControllers]; NSArray *tabArray = [self getTabArray]; self.mainTabVC = [[MainTabBarViewController alloc] init:tabArray]; self.window.rootViewController = self.mainTabVC; [self.window setHidden:false]; ... } Added these 2 delegate functions to AppDelegate What I'm trying to achieve:
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
150
Jul ’25
UITabBarController ignores UITab view controllers when in UITabGroup
When composing tabs like this and selecting them in the sidebar, only the group's view controller is ever displayed, even when selecting the individual first and second tabs. Their view controllers are just ignored. Am I immensely stupid here or is this a bug in iPadOS 26 beta 3? // First tab let firstTab = UITab( title: "First", image: UIImage(systemName: "heart"), identifier: "hello" ) { _ in UINavigationController(rootViewController: ViewController()) } // Second tab let secondTab = UITab( title: "Second", image: UIImage(systemName: "heart"), identifier: "hello2" ) { _ in UIViewController() } // Tab group let tabGroup = UITabGroup( title: "Stuff", image: nil, identifier: "stuff", children: [firstTab, secondTab] ) { _ in ViewController() } let tbc = UITabBarController(tabs: [tabGroup]) tbc.mode = .tabSidebar
Topic: UI Frameworks SubTopic: UIKit
3
0
180
Jul ’25
iPadOS 26 TabBar text color can't be changed
Hello, I have been trying for some time to change the color of native UITabBar in UITabBarController through UITabBarAppearance, but nothing works and the text is still black in the Xcode Beta 3 on iPadOS 26 while it works correctly in the previous OS versions. Here is the code: let color = UIColor.white let stackedAppearance = UITabBarItemAppearance() stackedAppearance.normal.iconColor = color stackedAppearance.normal.titleTextAttributes = [ .foregroundColor: color ] stackedAppearance.selected.iconColor = color stackedAppearance.selected.titleTextAttributes = [ .foregroundColor: color ] let inlineAppearance = UITabBarItemAppearance() inlineAppearance.normal.iconColor = color inlineAppearance.normal.titleTextAttributes = [ .foregroundColor: color ] inlineAppearance.selected.iconColor = color inlineAppearance.selected.titleTextAttributes = [ .foregroundColor: color ] let tabAppearance = UITabBarAppearance() tabAppearance.compactInlineLayoutAppearance = inlineAppearance tabAppearance.inlineLayoutAppearance = inlineAppearance tabAppearance.stackedLayoutAppearance = stackedAppearance UITabBar.appearance().standardAppearance = tabAppearance UITabBar.appearance().scrollEdgeAppearance = tabAppearance
0
1
227
Jul ’25
Why does converting HEIC/HEIF to JPEG using UIImage.jpegData(compressionQuality: 1.0) significantly increase file size?
I'm working with images selected from the iOS Photos app using PHPickerViewController. Some images appear as HEIF in the Photos info panel — which I understand are stored in the HEIC format, i.e., HEIF containers with HEVC-compressed images, commonly used on iOS when "High Efficiency" is enabled. To convert these images to JPEG, I'm using the standard UIKit approach: if let image = UIImage(data: heicData) { let jpegData = image.jpegData(compressionQuality: 1.0) } However, I’ve noticed that this conversion often increases the image size significantly: Original HEIC/HEIF: ~3 MB Converted JPEG (quality: 1.0): ~8–12 MB There’s no resolution change or image editing — it’s just a direct conversion. I understand that HEIC is more efficient than JPEG, but the increase in file size feels disproportionate. Is this kind of jump expected, or are there any recommended workarounds to avoid it?
1
0
120
Jul ’25
Is super.init(frame: CGRect) the designated initialiser for a UICollectionViewCell class?
I was writing some code for a UICollectionViewCell class and I normally include this initialiser when I create a new subclass for UICollectionViewCell, and saw that frequently this is paired with a required init?(coder: NSCoder) initialiser, so I was wondering if super.init(frame: CGRect) is the designated initialiser for the UICollectionViewCell class?
Topic: UI Frameworks SubTopic: UIKit
1
0
243
Jul ’25
Who vends the item identifier and the index path arguments to the cell provider closure of a diffable data source?
I was reading over the documentation of the CellProvider struct for the diffable data source initialiser, and the CellProvider is defined as a closure which takes three arguments, a table view, an index path, and an item identifier. My question is, who vends the index path and the item identifier to this closure? My thinking is that it is the data source who vends these items because it adopts the UITableViewDataSource protocol which acts as the source of data for this view.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
241
Jul ’25
Layout Engine Crash on iOS 26: NSInternalInconsistencyException
Starting with iOS 26 beta, I'm encountering an intermittent crash in production builds related to Auto Layout and background threading. This crash did not occur on iOS 18 or earlier and has become reproducible only on devices running iOS 26 betas. We have already performed a thorough audit of our code: • Verified that all UIKit view hierarchy and layout mutations occur on the main thread. • Re-tested with strict logging—confirmed all remaining layout/constraint/view updates are performed on the main thread. • No third-party UI SDKs are used in the relevant flow. Despite that, the crash still occurs and always from a background thread, during internal UIKit layout commits. Fatal Exception: NSInternalInconsistencyException Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread. 0 MyApp 0x7adbc8 FIRCLSProcessRecordAllThreads + 172 1 MyApp 0x7adfd4 FIRCLSProcessRecordAllThreads + 1208 2 MyApp 0x7bc4b4 FIRCLSHandler + 56 3 MyApp 0x7bc25c __FIRCLSExceptionRecord_block_invoke + 100 4 libdispatch.dylib 0x1b7cc _dispatch_client_callout + 16 5 libdispatch.dylib 0x118a0 _dispatch_lane_barrier_sync_invoke_and_complete + 56 6 MyApp 0x7bb1f0 FIRCLSExceptionRecord + 224 7 MyApp 0x7bbd1c FIRCLSExceptionRecordNSException + 456 8 MyApp 0x7badf4 FIRCLSTerminateHandler() + 396 9 Intercom 0x86684 IntercomSDK_sentrycrashcm_cppexception_getAPI + 308 10 libc++abi.dylib 0x11bdc std::__terminate(void (*)()) + 16 11 libc++abi.dylib 0x15314 __cxa_get_exception_ptr + 86 12 libc++abi.dylib 0x152bc __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 90 13 libobjc.A.dylib 0x3190c objc_exception_throw + 448 14 CoreAutoLayout 0x13a4 -[NSISEngine optimize] + 314 15 CoreAutoLayout 0x1734 -[NSISEngine _optimizeWithoutRebuilding] + 72 16 CoreAutoLayout 0x1404 -[NSISEngine optimize] + 96 17 CoreAutoLayout 0xee8 -[NSISEngine performPendingChangeNotifications] + 104 18 UIKitCore 0x27ac8 -[UIView(Hierarchy) layoutSubviews] + 136 19 UIKitCore 0xfe760 -[UIWindow layoutSubviews] + 68 20 UIKitCore 0x234228 -[UITextEffectsWindow layoutSubviews] + 44 21 UIKitCore 0x27674 -[UIImageView animationImages] + 912 22 UIKitCore 0x28134 -[UIView(Internal) _viewControllerToNotifyOnLayoutSubviews] + 40 23 UIKitCore 0x18c2898 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2532 24 QuartzCore 0xabd98 CA::Layer::perform_update_(CA::Layer*, CALayer*, unsigned int, CA::Transaction*) + 116 25 QuartzCore 0x8e810 CA::Layer::update_if_needed(CA::Transaction*, unsigned int, unsigned int) + 600 26 QuartzCore 0xad45c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 200 27 QuartzCore 0x6e30c CA::Context::commit_transaction(CA::Transaction*, double, double*) + 540 28 QuartzCore 0x9afc4 CA::Transaction::commit() + 644 29 QuartzCore 0x16974c CA::Transaction::release_thread(void*) + 180 30 libsystem_pthread.dylib 0x4c28 _pthread_tsd_cleanup + 620 31 libsystem_pthread.dylib 0x4998 _pthread_exit + 84 32 libsystem_pthread.dylib 0x5e3c pthread_atfork + 54 33 libsystem_pthread.dylib 0x1440 _pthread_wqthread + 428 34 libsystem_pthread.dylib 0x8c0 start_wqthread + 8 Any ideas?
4
3
416
Jul ’25