Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

Why is the nib still loaded even though the class has been registered with NSCollectionView?
I implemented a subclass of NSCollectionViewItem: class ViewItem: NSCollectionViewItem { override func loadView() { self.view = NSView() } } and registed to NSCollectionView: class PictureFrameThemeListView: NSCollectionView { init(viewModel: PictureFrameViewModel) { super.init(frame: .zero) self.register(ViewItem.self, forItemWithIdentifier: .item) } However, when calling makeItem(withIdentifier:for:), the following error is prompted: FAULT: NSInternalInconsistencyException: -[NSNib _initWithNibNamed:bundle:options:] could not load the nib 'Item' in bundle NSBundle What confuses me is that I registered the subclass of NSCollectionViewItem, why do NSCollectionView to init the NSNib?
Topic: UI Frameworks SubTopic: AppKit Tags:
2
0
32
2w
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
62
2w
AVCaptureVideoPreviewLayer not working in iPadOS26 when using Windowed Apps mode
In the current beta of iPadOS 26.0 (23A5297m), the camera does not function properly when the following conditions are met: The device is set to Windowed Apps mode in the Settings app. Multiple application windows are present on one screen. Using AVCaptureVideoPreviewLayer. On the other hand, UIImagePicker works properly. Is this a specification of iPadOS 26 that cannot be avoided? Or is there an official solution or workaround available?
Topic: UI Frameworks SubTopic: General
1
1
35
2w
PaperKit and PKDrawing in iPadOS 26 beta
I’ve been testing out PaperKit from beta 1 up until 3, then took a break and on my return at beta 7 I find that the .drawing property of the PaperMarkup data model has been removed, i.e. a PKDrawing can no longer be added / modified on PaperKit. Also, the shape recognition feature seems to have been removed. I see this as a tremendous drawback. I filed feedback already: FB19893338 Please bring it back.
1
0
67
2w
Borderless NavigationLink broken in tvOS 26
NavigationLinks do not display correctly in tvOS 26. When using a Button, the correct behavior of vertically placing an Image or AsyncImage above one or two Text fields occurs. However, when using NavigationLink the image and text(s) are laid out horizontally. Attempting to fix this using a VStack prevents the text from sliding down as the NavigationLink receives focus. Using the hoverEffect modifier does not help. Using a Button (correct behavior): Using a NavigationLink without VStack: Using a NavigationLink with VStack:
3
1
101
2w
"Unwrapping" Scrolling
For a number of complex views in my app, I need to embed scrollable objects (like List, Form or TextEditor) in a ScrollView. To do that, I need to apply a limit to the height of the embedded object. What I would like to do is set that limit to the actual height of the content being displayed in the List, Form, TextEditor, etc. (Note that this height calculation should be dynamic, so that content changes are properly displayed. I attempted the following: @State listHeight: CGFloat = .zero List { ... content here } .onScrollGeometryChange(for: CGFloat.self, of: { geometry in return geometry.contentSize.height }, action: { oldValue, newValue in if oldValue != newValue { listHeight = newValue } }) .frame(height: listHeight) .scrollDisabled(true) This does not work because geometry.contentSize.height is always 0. So it is apparent that .onScrollGeometryChangedoes not interact with the internal scrolling mechanism of List. (Note, however, that.scrollDisabled` does work.) Does anyone have a suggestion on how I might get this to work?
3
0
109
2w
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
101
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
106
2w
Zooming between SwiftUI and Storyboards
This is probably abusing the system more than it should be but maybe it is somehow possible. I have: An objective-C based storyboard iPad OS app. I'm beginning to adopt SwiftUI. I have a hosting controller with a content view that has a lazygrid of cards, which have an NSManagedObject for data. On tapping a card, a detail view opens, if in multi-tasking, a new window, if not, pushing the navigation controller (this detail view still exists in UIKit/ObjC, and is handled by sending a notification with the ObjectID, which then triggers a storyboard segue to the detail.) I have zoom transitions on all my things. They work great in Obj.C, especially now with the bar button source. On my iPhone target, I still have an old tableview, and I'm able to zoom properly - if someone changes the detail view's managed object (through a history menu), the zoom context looks up where the tableview is, and scrolls to it while popping. I'd like to somehow do this on the lazygrid - first) to just have an individual card be the zoom source, it should be able to know what the source view is to say in the prepareForSegue method just to zoom at all. and second) if the detail has changed the current ObjectID (which gets passed around as a notification), to somehow scroll the lazygrid to the right object before popping. I've looked at https://developer.apple.com/tutorials/SwiftUI/interfacing-with-uikit but this seems like swiftUI is the host. I have it the other way around, uikit hosting swiftUI pushing uikit. TIA for any pointers
1
0
80
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
61
2w
On macOS, what is the appropriate way to disable the sidebar material in a NavigationSplitView?
If you create a NavigationSplitView, then the sidebar is automatically adorned with a sidebar material effect. This affects the views background as well as any controls that are in the view. What is the correct way to disable this behaviour so that I can use a NavigationSplitView without the material effects being applied? The best I've come up with so far is to explicitly set the background on the sidebar but I'm curious if that's the correct way or I'm just getting lucky. struct ContentView: View { var body: some View { NavigationSplitView { // This works, but is it correct? SidebarView() .background(.windowBackground) } detail: { DetailView() } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
4
0
119
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
3
363
2w
Toolbar tint color with Liquid Glass
I'm adapting a UIKit app to work with Liquid Glass. In pre-Liquid Glass days, the application window had a tintColor that was passed down to all of its descendant views, resulting in toolbar buttons that match the app's color scheme. In iOS 26, my toolbar buttons are always black, no matter what. I've tried setting the UIBarButtonItem#tintColor on the button and setting UIBarButtonAppearanc#tintColor. The buttons are still black. What am I doing wrong? I see a tintColor modifier for SwiftUI toolbar buttons, so it seems like maybe you can do this with SwiftUI. Many of the built-in apps on iOS 26 beta have only black toolbar buttons - is it not possible to change the toolbar button tint color on iOS 26?
Topic: UI Frameworks SubTopic: General
1
0
274
2w
In SwiftUI for macOS, how can you detect if a view or any ancestor is "hidden"?
Given a View in SwiftUI for macOS, how can I tell if that view is hidden either because it, or any of its ancestor's opacity is 0.0 or the .hidden modifier has been applied? Presumably I can manually do this with an Environment value on the ancestor view, but I'm curious if this can be done more idiomatically. An example use case: I have views that run long-running Tasks via the .task(id:) modifier. These tasks only need to be running if the View itself is visible to the user. When the View is hidden, the task should stop. When the View reappears, the Task should restart. This happens automatically when Views are created and destroyed, but does not happen when a view is only hidden.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
2
0
79
2w
How do you compute backing pixel alignment in SwiftUI's `Layout`?
When performing custom layout in AppKit, it's essential that you pixel align frames using methods like backingAlignedRect. The alignment differs depending on the backingScaleFactor of the parent window. When building custom Layouts in SwiftUI, how should you compute the alignment of a subview.frame in placeSubviews() before calling subview.place(...)? Surprisingly, I haven't seen any mention of this in the WWDC videos. However, if I create a Rectangle of width 1px and then position it on fractional coordinates, I get a blurry view, as I would expect. Rounding to whole numbers works, but on Retina screens you should be able to round to 0.5 as well. func placeSubviews( in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout Void ) { // This should be backing aligned based on the parent window's backing scale factor. var frame = CGRect( x: 10.3, y: 10.8, width: 300.6, height: 300.1 ) subview.place( at: frame.origin, anchor: .topLeading, proposal: ProposedViewSize(frame.size) ) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
1
0
50
2w
TabView with NavigationStack issue on macOS Tahoe Beta 7
I have an app using TabView with multiple Tabs using tabViewStyle „sidebarAdaptable“. Each Tab does have its own NavigationStack. When I switch multiple times between the tabs and append a child view to one of my navigation stacks, it will stop working after a few tries with the following error „A NavigationLink is presenting a value of type “HomeStack” but there is no matching navigationDestination declaration visible from the location of the link. The link cannot be activated. Note: Links search for destinations in any surrounding NavigationStack, then within the same column of a NavigationSplitView.“ The same code is working fine on iOS, iPadOS but not working on macOS. When I remove tabViewStyle of sidebarAdaptable it’s also working on macOS. I shrinked it down to a minimal reproducible code sample. Any idea if that is a bug or I'm doing something wrong? struct ContentView: View { @State private var appState: AppState = .init() var body: some View { TabView(selection: $appState.rootTab) { Tab("Home", systemImage: "house", value: RootTab.home) { NavigationStack(path: $appState.homeStack) { Text("Home Stack") NavigationLink("Item 1", value: HomeStack.item1) .padding() NavigationLink("Item 2", value: HomeStack.item2) .padding() .navigationDestination(for: HomeStack.self) { stack in Text("Stack \(stack.rawValue)") } .navigationTitle("HomeStack") } } Tab("Tab1", systemImage: "gear", value: RootTab.tab1) { NavigationStack(path: $appState.tab1Stack) { Text("Tab 1 Stack") NavigationLink("Item 1", value: Tab1Stack.item1) .padding() NavigationLink("Item 2", value: Tab1Stack.item2) .padding() .navigationDestination(for: Tab1Stack.self) { stack in Text("Stack \(stack.rawValue)") } .navigationTitle("Tab1Stack") } } } .tabViewStyle(.sidebarAdaptable) .onChange(of: appState.rootTab) { _, _ in appState.homeStack.removeAll() appState.tab1Stack.removeAll() } } } @MainActor @Observable class AppState { var rootTab: RootTab = .home var homeStack: [HomeStack] = [] var tab1Stack: [Tab1Stack] = [] } enum RootTab: Hashable { case home case tab1 case tab2 } enum HomeStack: String, Hashable { case home case item1 case item2 } enum Tab1Stack: String, Hashable { case home case item1 case item2 }
0
0
65
2w
iOS 26 (beta 7) setting .searchFocused programmatically does not work
Already filed a feedback in case this is a bug, but posting here in case I'm doing something wrong? I'd like the search field to automatically be displayed with the keyboard up when the view appears. This sample code works in iOS 18, but it does not work in iOS 26 beta 7 I also tried adding a delay to setting searchIsFocused = true but that did not help struct ContentView: View { var body: some View { NavigationStack { NavigationLink(destination: ListView()) { Label("Go to list", systemImage: "list.bullet") } } .ignoresSafeArea() } } struct ListView: View { @State private var searchText: String = "" @State private var searchIsPresented: Bool = false @FocusState private var searchIsFocused: Bool var body: some View { ScrollView { Text("Test") } .searchable(text: $searchText, isPresented: $searchIsPresented, placement: .automatic, prompt: "Search") .searchFocused($searchIsFocused) .onAppear { searchIsFocused = true } } }
1
0
53
2w
Force a locale from string catalog
I'm writing an iOS app that shares content with buddies. So my app will run in one language but the shared content will use the locale configured for the buddy. I found this Apple documentation which suggests that locale: (Locale(identifier: is the solution. Apple Documentation But I can't get it to work. Here's sample code. struct LocalizationDemoView: View { @State var isEnglish = true var body: some View { var myLocale: String { isEnglish ? "en": "de" } VStack { Toggle("Switch language", isOn: $isEnglish).frame(maxWidth: 200) HStack { Text("\(myLocale): ") Text(String(localized: "Hello world!", locale: (Locale(identifier: myLocale)), comment: "To share")) } } } } And here's the excerpt from the string catalog: { "sourceLanguage" : "en", "strings" : { "Hello world!" : { "comment" : "To share", "localizations" : { "de" : { "stringUnit" : { "state" : "translated", "value" : "🇩🇪 Moin Welt!" } }, "en" : { "stringUnit" : { "state" : "translated", "value" : "🇬🇧 Hello world!" } } } } } } Has Apple reduced support for string catalogs or is my code wrong? Xcode 16.4 compiled on MacOS 15.6.1, device iOS 18.6.2
4
0
204
2w