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

Created

How to prevent window scene restoration
We have an iOS app running on macOS (not Mac Catalyst). The preferences are in a dedicated UIWindowScene. We don't want this scene to be restored, so when you start the app the preferences shouldn't be visible. How can we prevent the UIWindowScene restoration? Alternatively, if we can't prevent it, how can we ensure the main window scene is in front of the preferences window scene on app start?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
32
6d
How to disable highlight state on Link in LA widget
I am working on a Live Activity widget. In it, I want some of the elements to open different deeplink URLs. I have found that assigning multiple widgetURL doesn't work, only one of the URLs gets opened no matter where you tap. I also found that Buttons don't seem to do anything, tapping them actually just open my app as if I just tapped a naked Live Activity. I have found that really only Link elements work if I want to open different URLs upon tapping different elements. And Links are cool and fine, but I am seeing that on tap, my elements become tinted... As in, there is a highlighted state, and it makes the elements inside blue. I have tried to use button style API on a link, but it didn't work. How can I disable the highlighted state for a Link element in a live activity widget?
0
0
45
6d
iOS 26 WKWebView STScreenTimeConfigurationObserver KVO Crash
Fatal Exception: NSInternalInconsistencyException Cannot remove an observer <WKWebView 0x135137800> for the key path "configuration.enforcesChildRestrictions" from <STScreenTimeConfigurationObserver 0x13c6d7460>, most likely because the value for the key "configuration" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the STScreenTimeConfigurationObserver [class.] I noticed that on iOS 26, WKWebView registers STScreenTimeConfigurationObserver, Is this an iOS 26 system issue? What should I do?
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
64
6d
UIBarButtonItem and Liquid Glass
I am looking for a way to change the liquid glass background colors on UIBarButtonItems. Setting tintColor does what I want for a bar button item when it is both the default button and it is enabled. But it does not seem to do anything for disabled buttons or non-prominent buttons. Also, is there a way to apply such a change using a UINavigationBarAppearance or a UIBarButtonItemAppearance? If I cannot change this liquid glass color, I might need to disable liquid glass on these by setting hidesSharedBackground to true. Is there a way to do this globally within the app (without using UIDesignRequiresCompatibility), or with something like UINavigationBarAppearance or UIBarButtonItemAppearance? Thank you. John
Topic: UI Frameworks SubTopic: UIKit
2
0
146
6d
Share Sheet with UIActivityItemsConfiguration
I am trying to address an issue with my app’s share sheet where, when the user sends a URL to either Apple Reminders or OmniFocus, the receiving app does not get a title. So I am updating my share sheet code to use UIActivityItemsConfiguration. I have this code: let title = "Golden Hill Software" let url = URL(string: "https://www.goldenhillsoftware.com/")! let itemProvider = NSItemProvider() itemProvider.registerObject(ofClass: URL.self, visibility: .all) { (handler) in handler(url, nil) return nil } let config = UIActivityItemsConfiguration(itemProviders: [itemProvider]) config.metadataProvider = { (key) in if key == .title || key == .messageBody { return title } else { return nil } } let viewController = UIActivityViewController(activityItemsConfiguration: config) self.present(viewController, animated: true) This works with some share sheet extensions. But when I choose the Ivory share extension, Ivory creates a post with a URL that starts with bplist…. When I choose the Open in Chrome action extension, Chrome says “Chrome cannot handle this link”. Can someone help me understand what I am doing wrong here? (edited)
Topic: UI Frameworks SubTopic: UIKit
0
0
26
6d
Delete Confirmation Dialog Inside Toolbar IOS26
inline-code How do you achieve this effect in toolbar? Where is the documentation for this? How to make it appear top toolbar or bottom toolbar? Thank you! Here is what I have now... .toolbar { ToolbarItem(placement: .destructiveAction) { Button { showConfirm = true } label: { Image(systemName: "trash") .foregroundColor(.red) } } } .confirmationDialog( "Are you sure?", isPresented: $showConfirm, titleVisibility: .visible ) { Button("Delete Item", role: .destructive) { print("Deleted") } Button("Archive", role: .none) { print("Archived") } Button("Cancel", role: .cancel) { } } }
0
0
31
6d
How do I prevent screenshots using SwiftUI?
Hi Team, How do I prevent screenshots using SwiftUI. I was using this solution on UIKit: extension UIView { func makeSecure() { DispatchQueue.main.async { let protectedView = UIView() self.superview?.addSubview(protectedView) // constraints... let secureView = SecureView() self.superview?.addSubview(secureView) // constraints... secureView.addSecureSubview(self) // constraints... } } } class SecureView: UIView { private lazy var secureField: UIView = { var secureField: UIView = UIView() // ... if let secureContainer = SecureField().secureContainer { secureField = secureContainer } ... return secureField }() required init() { ... } } Is it posible to do the same thing using SwiftUI. Do we have an example? What would you recommend when we work with confidencial information in SwiftUI like bank account information? Thanks in advance!
0
0
115
6d
Zoom navigation transitions for tabViewBottomAccessory are not working in SwiftUI with ObservableObject or Observable
The zoom navigation transition with matchedTransitionSource in tabViewBottomAccessory does not work when a Published var in an ObservableObjector Observable gets changed. Here is an minimal reproducible example with ObservableObject: import SwiftUI import Combine private final class ViewModel: ObservableObject { @Published var isPresented = false } struct ContentView: View { @Namespace private var namespace @StateObject private var viewModel = ViewModel() // @State private var isPresented = false var body: some View { TabView { Button { viewModel.isPresented = true } label: { Text("Start") } .tabItem { Image(systemName: "house") Text("Home") } Text("Search") .tabItem { Image(systemName: "magnifyingglass") Text("Search") } Text("Profile") .tabItem { Image(systemName: "person") Text("Profile") } } .sheet(isPresented: $viewModel.isPresented) { Text("Sheet") .presentationDragIndicator(.visible) .navigationTransition(.zoom(sourceID: "tabViewBottomAccessoryTransition", in: namespace)) } .tabViewBottomAccessory { Button { viewModel.isPresented = true } label: { Text("BottomAccessory") } .matchedTransitionSource(id: "tabViewBottomAccessoryTransition", in: namespace) } } } However, when using only a State property everything works: import SwiftUI import Combine private final class ViewModel: ObservableObject { @Published var isPresented = false } struct ContentView: View { @Namespace private var namespace // @StateObject private var viewModel = ViewModel() @State private var isPresented = false var body: some View { TabView { Button { isPresented = true } label: { Text("Start") } .tabItem { Image(systemName: "house") Text("Home") } Text("Search") .tabItem { Image(systemName: "magnifyingglass") Text("Search") } Text("Profile") .tabItem { Image(systemName: "person") Text("Profile") } } .sheet(isPresented: $isPresented) { Text("Sheet") .presentationDragIndicator(.visible) .navigationTransition(.zoom(sourceID: "tabViewBottomAccessoryTransition", in: namespace)) } .tabViewBottomAccessory { Button { isPresented = true } label: { Text("BottomAccessory") } .matchedTransitionSource(id: "tabViewBottomAccessoryTransition", in: namespace) } } }
0
0
64
6d
@state update not reflecting on UI.
I’m facing an issue in our native iOS app that occurs specifically on iOS 26.1 (not observed on any lower versions). When I update a @State field value, the UI does not reflect the change as expected. The @State variable updates internally, but the view does not re-render. This behaviour started after upgrading to iOS 26.1. Works fine on iOS 26.0 and earlier versions. Has anyone else encountered this issue or found a workaround? Any insights or suggestions would be greatly appreciated.
5
0
211
1w
PHPickerViewController displays the photo picker with shrunken UI
I need to create a Mac application using Objective-C. The application has to use PHPickerViewController to provide user a familiar interface to pick photos. Here is the Objective-C code that used to present the photo picker. //ViewController.h #import <Cocoa/Cocoa.h> #import <PhotosUI/PhotosUI.h> @interface ViewController : NSViewController<PHPickerViewControllerDelegate> @property (nonatomic, weak) IBOutlet NSImageView *myImageView; @end // ViewController.m @implementation ViewController PHPickerViewController* pickerViewController = nil; - (void)pickPhotos { PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init]; config.selectionLimit = 0; // Allow multiple selections config.filter = [PHPickerFilter imagesFilter]; // Filter for images pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config]; pickerViewController.preferredContentSize = NSMakeSize(800, 600); pickerViewController.delegate = self; // Set the delegate to handle selection [self presentViewControllerAsModalWindow:pickerViewController]; - (IBAction)clicked:(id)sender { NSLog(@"Button Clicked"); [self pickPhotos]; } - (void)picker:(PHPickerViewController *)picker didFinishPicking:(NSArray<PHPickerResult *> *)results { if (pickerViewController) { [picker dismissViewController:pickerViewController]; } } @end Can you please guide me to show the photo picker to a bigger size?
Topic: UI Frameworks SubTopic: AppKit
4
0
120
1w
SwiftUI: NavigationSplitView + Toolbar + Button = Constraint Warning
As the title says, when I try to add a Toolbar with a Button to my NavigationSplitView I get a warning about satisfying constraints. Here is a minimal reproducible example: import SwiftUI @main struct ViewTestingApp: App { var body: some Scene { WindowGroup { NavigationSplitView { Text("Sidebar") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button { debugPrint("Hello World!") } label: { Label("", systemImage: "flame") } } } } content: { Text("Content") } detail: { Text("Detail") } } } } This is the specific warning I get: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x600002164960 h=--& v=--& _TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x100f80fa0.width == 0 (active)>", "<NSLayoutConstraint:0x600002160370 _TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x100f80fa0.leading == _UIButtonBarButton:0x100f7d360.leading (active)>", "<NSLayoutConstraint:0x6000021603c0 H:[_UIButtonBarButton:0x100f7d360]-(0)-| (active, names: '|':_TtCC5UIKit19NavigationButtonBar15ItemWrapperView:0x100f80fa0 )>", "<NSLayoutConstraint:0x600002160050 'IB_Leading_Leading' H:|-(2)-[_UIModernBarButton:0x100f7e6c0] (active, names: '|':_UIButtonBarButton:0x100f7d360 )>", "<NSLayoutConstraint:0x6000021600a0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x100f7e6c0]-(2)-| (active, names: '|':_UIButtonBarButton:0x100f7d360 )>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000021600a0 'IB_Trailing_Trailing' H:[_UIModernBarButton:0x100f7e6c0]-(2)-| (active, names: '|':_UIButtonBarButton:0x100f7d360 )> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. The project settings are all at their defaults, but in case anyone wants to try it with the whole project: https://github.com/OddMagnet/ViewTesting
Topic: UI Frameworks SubTopic: SwiftUI
3
0
97
1w
UIKit - Stop ongoing animation on the extended setVisibleMapRect Animation time on MapKit
Hi team, I've been trying to extend the animation when we call the function setVisibleMapRect, we can use UIView.animate to lengthen the animation time, but one thing that I found not working is that when I extend the animation to 3, 5, or 10 seconds, and the changes is still ongoing and there's a gesture performed, the map will completely ignore the gesture. Causing the map to be having this kind of like "delayed" or "freeze" experience for the user. The map will immediately move to the final rect and ignores the user gesture. I've been checking on this problem for a week now and I'm quite stuck. I've tried using CADisplayLink to manually animate the camera per system fresh rate, it works very well, I can stop the camera movement anytime there are touches, but it causes the resource CPU spikes. Removing the animation layers recursively on sublayers and subviews also doesn't help. While storing the animation into a UIViewPropertyAnimator and use stopAnimation will always ignores user first interactions too while also animating the camera to the final position (which is not expected).
2
0
75
1w
SwiftUI Map overlay z-order: make MapPolyline consistently render above MapPolygon (aboveLabels)
Hi, On a SwiftUI map I render a mix of MapPolygon and MapPolyline. All overlays must use the same overlay level (.aboveLabels). Goal: Ensure MapPolyline always renders on top of MapPolygon. Issue: I order data so polylines are last and even render in two passes (polygons first, polylines second), all at .aboveLabels. Despite that, after polygons change (items removed/added based on zoom levels), I see polygons visually on top of polylines. It seems MapKit may batch/reorder rendering internally. Questions: Is there a reliable way in SwiftUI Map to enforce z-order within the same overlay level so MapPolyline always appears above MapPolygon? If not, any known workarounds or best practices? (e.g. different composition patterns, using annotations with zIndex, or other techniques compatible with SwiftUI Map) I know you can do this with UIKit, but first looking for a solution compatible with SwiftUI's version of MapKit. Thanks
0
0
55
1w
How to move focus across multiple textfields using arrow keys/enter key in iOS
Hi. I have an iOS application with multiple input fields. I have to design an experience such that whenever the user presses enter key on a textfield, it should move focus to the next input field. Similarly, consider a stack of 3 textfields, I want to cycle the focus as and when the user presses up/down arrow keys. Other platforms like Android, have this feature out-of-the-box. I wanted to understand if iOS also supports this kind of behavior. I know how to manually code such UX, but just wanted to confirm whether there is some inherent feature like on android which i can leverage? Thanks.
0
0
37
1w
Flutter iOS - EXC_BAD_ACCESS crash on cold start after app was killed, affects ~1-2% of users
Question: How to prevent Flutter app crash on iOS 18 during cold start when iOS traverses view hierarchy before Flutter engine is fully initialized? Help needed: Looking for a way to either delay iOS view hierarchy traversal or ensure Flutter is fully initialized before iOS lifecycle callbacks fire. Problem Summary Our Flutter app crashes on cold start for approximately 1-2% of iOS users. The crash occurs specifically on iOS and only under these exact conditions: When crash happens: User opens app and uses it normally ✅ User minimizes app (goes to background) ✅ User returns to app from background ✅ (works fine) User kills app from app switcher (swipe up to close) User taps app icon to launch again → CRASH ❌ Key observations: Crash is intermittent - app may open on 2nd, 3rd, or 5th attempt 100% reproducible on affected devices by repeating kill→launch cycle ~98% of users have no issues Environment Flutter: 3.38.3 Crash Logs (from Sentry) Crash Type 1: Stack Overflow (most common) OS Version: iOS 18.7.2 (22H124) Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: BUS_NOOP at 0x000000016ad5be90 Application Specific Information: compare:options:range:locale: > Stack overflow in (null) Thread 0 Crashed: 0 CoreFoundation CFStringGetLength 1 CoreFoundation CFStringCompareWithOptionsAndLocale 2 CoreFoundation 3 libsystem_c bsearch 4 CoreFoundation 5 UIKitCore ... 15-99: UIKitCore 0x30e177148 [inlined] // 85+ recursive calls Crash Type 2: Use-After-Free Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: SEGV_NOOP at 0x0500007f14000000 KERN_INVALID_ADDRESS at 0x500007f14000000 Thread 0 Crashed: 0 libobjc.A.dylib objc_retainAutoreleaseReturnValue 1 UIKitCore ... 6 libobjc.A.dylib objcrootDealloc 7 QuartzCore // CALayer operations What We Tried (nothing solved cold start crash) Attempt Result Increased stack size to 64MB (-Wl,-stack_size,0x4000000) ❌ No effect Disabled iOS State Restoration ❌ No effect Added isViewLoaded checks in AppDelegate ❌ No effect Added try-catch around GetStorage/SecureStorage init ❌ No effect Added isAppActive flag to track app state ❌ No effect Snapshot overlay in applicationWillResignActive ✅ Fixed background→foreground crash, ❌ but NOT cold start Current AppDelegate.swift import UIKit import Flutter @main @objc class AppDelegate: FlutterAppDelegate { private var snapshotView: UIView? private var isAppActive = false override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) window?.overrideUserInterfaceStyle = .light isAppActive = true return super.application(application, didFinishLaunchingWithOptions: launchOptions) } override func application(_ application: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> Bool { return false } override func application(_ application: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool { return false } override func applicationWillResignActive(_ application: UIApplication) { guard isAppActive, let window = self.window, let rootVC = window.rootViewController, rootVC.isViewLoaded, snapshotView == nil else { return } let snapshot = UIView(frame: window.bounds) snapshot.backgroundColor = .white snapshot.tag = 999 window.addSubview(snapshot) snapshotView = snapshot } override func applicationDidBecomeActive(_ application: UIApplication) { guard snapshotView != nil else { isAppActive = true return } snapshotView?.removeFromSuperview() snapshotView = nil } }
Topic: UI Frameworks SubTopic: UIKit
1
0
82
1w
Flutter iOS crash on cold start - EXC_BAD_ACCESS Stack overflow in UIKit view hierarchy
I'm experiencing intermittent crashes on iOS when launching a Flutter app after it was killed from the app switcher. The app works fine when resumed from background. Environment: Flutter 3.38.3 Crash signature: EXC_BAD_ACCESS (SIGBUS) Stack overflow in (null) compare:options:range:locale: > Thread 0: CFStringGetLength → CFStringCompareWithOptionsAndLocale → UIKitCore ( 85+ inlined recursive calls) What I've tried: Increased stack size to 64MB (-Wl,-stack_size,0x4000000) - didn't help Disabled iOS State Restoration - didn't help Added snapshot overlay in applicationWillResignActive - helped for background issue, but not cold start Key observation: The crash happens intermittently. Sometimes the app opens on 2nd attempt, sometimes on 5th. This suggests a race condition between Flutter engine initialization and iOS view hierarchy traversal. Question: Is there a way to delay iOS view hierarchy operations until Flutter is fully initialized? Any help appreciated!
Topic: UI Frameworks SubTopic: UIKit
1
0
85
1w
[Xcode 26.2] Weird animation of first-level view controller being pushed on iOS 26 (with hidesBottomBarWhenPushed)
Hi. We discovered this strange behaviour when we're planning to migrate to Xcode 26.2 RC. When our app is running on iOS 26, view controllers thar are pushed from the root of UITabBarController will show with an animation. The views are growing from either the top-left or bottom-right corner. This only happens when the hidesBottomBarWhenPushed variable is set to true. Also it only happens to view controllers that are pushed directly from a UITabBarController; subsequent view controllers that are pushed will not have this weird animation. Since our app design requires hidesBottomBarWhenPushed to be true, we are asking if there is any way to fix this animation. Please refer to the following gif: We have tried methods described in this article but it doesn't work all the time: https://darjeelingsteve.com/articles/Fixing-UINavigationController-Push-Animation-Layout-Issues-on-iOS-26.html. We've tried the following three methods: This does not work at all. First-level view controllers are still showing with animation. override func pushViewController(_ viewController: UIViewController, animated: Bool) { super.pushViewController(viewController, animated: animated) transitionCoordinator?.animate { _ in UIView.performWithoutAnimation { viewController.view.layoutIfNeeded() } } } This does not work as well. override func pushViewController(_ viewController: UIViewController, animated: Bool) { super.pushViewController(viewController, animated: animated) transitionCoordinator?.animate(alongsideTransition: { [weak self] _ in UIView.performWithoutAnimation { self?.navigationBar.layoutIfNeeded() } }, completion: nil) } This works sometimes. However it breaks the push animation for some view controllers. override func pushViewController(_ viewController: UIViewController, animated: Bool) { super.pushViewController(viewController, animated: animated) UIView.performWithoutAnimation { viewController.view.layoutIfNeeded() } } We've created a simple sample project that reproduces this problem. Please run it on a simulator running iOS 26. https://drive.google.com/file/d/1q3pokphh1YDINH69LrHuqJQe8MijHQ2m/view?usp=sharing If anyone has a solution to this please let me know. Thank you for reading.
Topic: UI Frameworks SubTopic: UIKit
0
0
85
1w
SwiftUI - presentationDetents behaves incorrectly on iOS 16–18 but works correctly on iOS 26
I'm using a custom modifier called AutoSheetDetentModifier to automatically size a sheet based on its content. On iOS 26, it works as expected: the content height is measured correctly and the sheet shrinks to match that height. However, on iOS 16, 17 and 18, the same code doesn’t work. The content height is still measured, but the sheet does not reduce its height. Instead, the sheet remains larger and the content appears vertically centered. (Note that content() includes ScrollView) public struct AutoSheetDetentModifier: ViewModifier { @State private var height: CGFloat = 380 // default value to avoid bouncing public func body(content: Content) -> some View { content .modifier(MeasureHeightViewModifier(height: $height)) .presentationDetents([.height(height)]) } } public struct MeasureHeightViewModifier: ViewModifier { @Binding var height: CGFloat public func body(content: Content) -> some View { content .fixedSize(horizontal: false, vertical: true) .background( GeometryReader { geo -> Color in DispatchQueue.main.async { height = geo.size.height } return Color.clear } ) } } extension View { public func applyAutoSheetDetent() -> some View { self .modifier(AutoSheetDetentModifier()) } } public var body: some View { VStack { header() content() // includes ScrollView footer() } .background(Color.customGray) .applyAutoSheetDetent() } func content() -> some View { ScrollView { VStack { ForEach(items) { item in itemRow(item) } } } .frame(maxHeight: UIScreen.main.bounds.height * 0.7) } Screenshot from iOS 26 (working as expected): Screenshot from iOS 18 (not working): How can I make .presentationDetents(.height) shrink the sheet correctly on iOS 16–18, the same way it does on iOS 26?
1
0
104
1w
Liquid Glass TabBar animations causes Hangs, bug with UIKitCore?
With iOS 26.1 we started seeing a bug that only appears on iPhone Air. This bug is visible with simulators too. I have tried so many different ways to fix the issue, but Instruments Profiler is pointing at UIKitCore. We load a tab bar, when the user attempts to switch a tab, the app hangs and never recovers. It happens right as the animation of the Glass bubble is in progress. I have tried a UIKit Tab bar, a SwiftUI Tab bar. I tore out AppDelegate and did a direct @main SwiftUI entry for my application. This issue appears with every tab bar instance I try. I attempted to disable LiquidGlass by utilizing this flag UIDesignRequiresCompatibility in my plist, but the flag seems to be ignored by the system. I am not sure what else to try. I have a trace file if that is helpful. What else can I upload? Here is what the code looks like. struct ContentView: View { @State private var selectedTab = 2 var body: some View { TabView(selection: $selectedTab) { Text("Profile") .tabItem { Label("Me", systemImage: "person") } .tag(0) Text("Training") .tabItem { Label("Training", systemImage: "calendar") } .tag(1) Text("Home") .tabItem { Label("Home", systemImage: "house") } .tag(2) Text("Goals") .tabItem { Label("Goals", systemImage: "target") } .tag(3) Text("Coach") .tabItem { Label("Coach", systemImage: "person.2") } .tag(4) } } } #Preview { ContentView() } and AppView entry point import SwiftUI @main struct RunCoachApp: App { var body: some Scene { WindowGroup { ContentView() } } }
6
1
347
1w