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

Document-based app always opens untitled document even when a document is restored
If my NSDocument.canConcurrentlyReadDocuments(ofType:) implementation returns true, often when launching the app, an untitled document is created regardless whether another document is restored. If document reading is not concurrent, an untitled document is only created when no other document is restored, as expected. The issue happens on most app launches when a document is restored. If the restored document takes long to load (which can be simulated by putting sleep(1) in the Document.read(from:ofType:) implementation), the issue always happens. Is this expected, or is there a workaround? I created FB25340015.
Topic: UI Frameworks SubTopic: AppKit Tags:
2
0
104
2d
UIDesignRequiresCompatibility = YES causes a crash on iOS 26 when built with Xcode 27. The key seems to follow the runtime OS, not the build SDK
Hi, I ran into a behavior of UIDesignRequiresCompatibility that doesn't match how I (and probably others) read the documentation. Environment Xcode: 27.2 Base SDK: iOS 27.2 Deployment target: iOS 18 Run destination: iOS 26.6 (physical device) Documentation The documentation states: "The system ignores this key when you build for iOS 27 or later, iPadOS 27 or later, Mac Catalyst 27 or later, macOS 27 or later, or tvOS 27 or later." I read "build for iOS 27" as a build-time condition: once the app is built with the iOS 27 SDK, the key no longer has any effect, whatever OS the app runs on. What I observed With UIDesignRequiresCompatibility = YES in Info.plist, I built the app against the iOS 27 SDK and ran it on iOS 26.6. The app crashes at launch. I removed only that key, did a clean build with the same configuration, and ran on the same iOS 26.6 device. The app runs normally. So in practice the key is not ignored for an app built for iOS 27. It looks like the decision is made by the OS the app runs on: iOS 27+ ignores the key, but iOS 26 still reads and applies it to a binary linked against the iOS 27 SDK, and that combination crashes. Questions What does "build for iOS 27 or later" refer to: the SDK the app is built with, the deployment target, or the OS the app runs on? My deployment target is iOS 18, so the app still runs on iOS 26. If the key is still honored there even when the app is built with the iOS 27 SDK, could the documentation say so explicitly? Is compatibility mode on iOS 26 for an app linked against the iOS 27 SDK an unsupported combination, and is the crash expected? Should developers simply remove the key when they adopt the iOS 27 SDK and still support iOS 26? Thanks!
Topic: UI Frameworks SubTopic: General Tags:
0
0
98
2d
iPhone Duo: Keep app on inner display while hinge is open (like Clock)?
I'm building a night-light app for iPhone Duo. When the device is partly open in tent mode, the lamp starts on the inner display. As soon as I set the phone down on a table, the system moves my window to the outer display, even though the hinge stays open. Apple's Clock app stays on the inner display in the same pose, so it seems possible at the system level. Steps Open iPhone Duo to ~80° (tent). Launch the app on the inner display. Set the device down on a table. Observed (logged from the app) UIHinge.status stays .partiallyOpen (~80°), not .closed. UIDevice.orientation goes portraitUpsideDown → faceDown → landscapeRight. UIScreen.didDisconnectNotification fires and UIScreen.screens drops the inner screen. The window moves to the outer screen (466×678). What I've tried Restricting UISupportedInterfaceOrientations to portrait only Turning on Rotation Lock Reading UIHingeInteraction (read-only, no effect on display routing) Looking at UISceneAccessory.cameraCapture, which only applies with an active capture session and a fully open device Question Is there a supported way for a scene to prefer or stay on the inner display while the hinge isn't closed? If not, I'll file a Feedback Assistant request. iPhone Duo · iOS 27.2 · Xcode 27.2
Topic: UI Frameworks SubTopic: SwiftUI
2
0
86
3d
iOS 27b3 SDK: iOS App on Mac crashes on UISearchBar focus
Our app crashes when compiled with the iOS 27 beta 3 SDK and run as an iOS app on Mac, on both macOS 26 and macOS 27, as soon as a UISearchBar receives focus. The crash is due to this exception: *** Assertion failure in BOOL _screenBasedFocusUnsupported(void)(), UIScreen.m:3.725 Accessing the focus system through UIScreen is no longer supported. ( 0 CoreFoundation 0x000000018bea31c0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018b91e91c objc_exception_throw + 88 2 Foundation 0x000000018e092644 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:] + 0 3 UIKitCore 0x00000001c5dae8ec _screenBasedFocusUnsupported + 272 4 UIKitCore 0x00000001c5dae960 -[UIScreen _preferredFocusedWindow] + 24 5 UIKitCore 0x00000001c4ea3a60 -[UIScreen _mainSceneReferenceBounds] + 200 6 UIKitCore 0x00000001c4ea3914 -[UIScreen _mainSceneBoundsForInterfaceOrientation:] + 40 7 UIKitCore 0x00000001c5708134 +[UINavigationBar defaultSizeForOrientation:] + 76 8 UIKitCore 0x00000001c6222c88 -[_UISearchPresentationController _layoutPresentationWithSize:transitionCoordinator:] + 704 9 UIKitCore 0x00000001c622296c -[_UISearchPresentationController containerViewWillLayoutSubviews] + 84 10 UIKitCore 0x00000001c549304c block_destroy_helper.13 + 25112 11 UIKitCore 0x00000001c549344c block_destroy_helper.13 + 26136 12 UIKitCore 0x00000001c4ea26a8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1648 13 QuartzCore 0x0000000196103dbc _ZN2CA5Layer15perform_update_EPS0_P7CALayerjNS_17LayerUpdateReasonEPNS_11TransactionE + 460 14 QuartzCore 0x000000019610390c _ZN2CA5Layer17update_if_needed_EPNS_11TransactionENS_17LayerUpdateReasonE + 692 15 QuartzCore 0x0000000196035d2c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 608 16 QuartzCore 0x0000000195e69520 _ZN2CA11Transaction6commitEv + 652 17 AppKit 0x0000000190fe116c __37+[NSDisplayCycle currentDisplayCycle]_block_invoke.7 + 44 18 CoreFoundation 0x000000018be34ad0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 19 CoreFoundation 0x000000018be34a10 __CFRunLoopDoBlocks + 396 20 CoreFoundation 0x000000018be33e54 __CFRunLoopRun + 2356 21 CoreFoundation 0x000000018bf06234 _CFRunLoopRunSpecificWithOptions + 532 22 HIToolbox 0x0000000198c1f560 RunCurrentEventLoopInMode + 320 23 HIToolbox 0x0000000198c228bc ReceiveNextEventCommon + 488 24 HIToolbox 0x0000000198dac14c _BlockUntilNextEventMatchingListInMode + 48 25 AppKit 0x00000001909163d0 _DPSBlockUntilNextEventMatchingListInMode + 228 26 AppKit 0x000000019026a084 _DPSNextEvent + 576 27 AppKit 0x0000000190dff96c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688 28 AppKit 0x0000000190dff678 -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] + 72 29 AppKit 0x000000019025d13c -[NSApplication run] + 368 30 AppKit 0x00000001902357b0 NSApplicationMain + 880 31 AppKit 0x000000019047c958 +[NSWindow _savedFrameFromString:] + 0 32 UIKitMacHelper 0x00000001aa2651bc UINSApplicationMain + 972 33 UIKitCore 0x00000001c4e1aed4 UIApplicationMain + 144 34 UIKitCore 0x00000001c548bda0 block_destroy_helper.31 + 8880 35 DigitalConcertHall.debug.dylib 0x0000000106e41bd8 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 128 36 DigitalConcertHall.debug.dylib 0x0000000106e41b4c $s18DigitalConcertHall11AppDelegateC5$mainyyFZ + 32 37 DigitalConcertHall.debug.dylib 0x0000000106e4afc0 __debug_main_executable_dylib_entry_point + 28 38 dyld 0x000000018b9ac4e4 start + 6992 ) I could not test with the iOS 27 beta 4 SDK due to this blocking issue: https://developer.apple.com/forums/thread/839012 However, when I tried to set up a simple sample project, I could not reproduce the issue. Does anybody know what might be causing this? I filed feedback FB24201508
8
2
2k
3d
Keeping the display awake during hands-free auto-scroll in a watchOS reading app
I develop Folito, a free watchOS app for reading EPUB books on Apple Watch. We added an auto-scroll mode: the text scrolls continuously at a speed the user sets with the Digital Crown, so they can read hands-free with their wrist raised. The display dims after the wake timeout because auto-scroll isn't user interaction, so the text becomes hard to read after 15–70 seconds while the user is still reading. What we've considered Pausing on isLuminanceReduced and resuming on tap. This works, but it needs a touch every minute. Continuing in Always On (luminance reduced) with ~1 Hz line-by-line updates. This is our current plan, but the text is dimmed and SE models have no Always On. WKExtendedRuntimeSession. None of the session types (self care, mindfulness, physical therapy, smart alarm, workout) describes reading, and we don't want to misuse one. HKWorkoutSession. Not appropriate, because it would record fake workouts. Questions Is there a supported way for a frontmost app to keep the display at normal brightness while showing continuously changing content the user is reading, without touch input? Would a WKExtendedRuntimeSession started only while auto-scroll runs (and ended as soon as it pauses or stops) be acceptable for this, and if so, which type? In Always On, what's the recommended way to keep text content advancing (for example, updating a ScrollView position via ScrollViewReader about once per second)? I found thread 720495 (iOS, isIdleTimerDisabled) and thread 122753 (Always On, 2019), but neither covers a watchOS app that needs the display awake while content advances on its own. Deployment target: watchOS 10, SwiftUI. Thanks!
1
0
263
3d
UIWindowScene sizeRestrictions minimumSize not working on iPadOS
Hello, following Apple docs and guidance from WWDC I'm trying to set a minimum size for my scene, for example I want it to minimally be 3/4 the width and height of the device. I've removed the UIRequiresFullScreen Info.plist property. The app does run in windowed mode and does have a resizing handle. I've implemented this UISceneDelegate: var window: UIWindow? var cameraWindow: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { window = UIWindow(windowScene: scene as! UIWindowScene) // setup root view controller let rootViewController: MainViewController = MainViewController(nibName: "Main", bundle: nil) let navController: NavigationController = NavigationController(rootViewController: rootViewController) navController.modalPresentationStyle = .fullScreen // set reasonable minimum sizes for WindowScene if let windowScene: UIWindowScene = scene as? UIWindowScene { if #available(iOS 16.0, *) { let windowSize: CGSize = windowScene.coordinateSpace.bounds.size windowScene.sizeRestrictions?.minimumSize.width = windowSize.width * 0.75 windowScene.sizeRestrictions?.minimumSize.height = windowSize.height * 0.75 } } window?.rootViewController = navController window?.makeKeyAndVisible() } } And proven via debugger that this code is being executed. I have the following observations: After setting these minimumSize properties I see the width and height both contain 0 afterwards, as if the property settings are discarding the value. I've even used hard-coded values instead of reading the coordinateSpace.bounds, to no avail. The scene is allowing resizing well below these minimums, about 1/3 the width and 1/2 the height. Anyone else observed this and have suggestions?
Topic: UI Frameworks SubTopic: UIKit
1
1
370
3d
Can I use a template image for quick actions?
Hey Team, System-provided quick actions in Finder sport a template image that adapts correctly to light and dark modes. However when I add a quick action extension in my app, the icon I refer to in the Info.plist renders in full color, even if it is defined in the asset catalog as a template image. This forces me to either use my app icon or a gray icon that will work in either appearance. How can I get the system-provided quick actions treatment? Thanks, Ari
Topic: UI Frameworks SubTopic: AppKit
2
1
320
4d
NavigationSplitView sidebar expansion temporarily oversizes split view and collapses toolbar search
[Submitted as FB25597038] Showing the sidebar in a two-column NavigationSplitView briefly collapses the toolbar search field, even though the window doesn't resize. Search is right-aligned on the detail container using .searchable, ToolbarSpacer(.flexible), and DefaultToolbarItem(kind: .search). The sample below uses static content and the native sidebar toggle and animation. Setting only the sidebar item's collapseBehavior to .useConstraints avoids the issue. It occurred in both recorded baseline expansions and neither expansion with the workaround. Environment macOS 27.2.1 (26B131) Xcode 27.2 (27B52) macOS SDK 27.2 (26B118) Native macOS app, arm64, deployment target macOS 27.0 Initial window: 906 × 600 points Sidebar minimum/ideal/maximum widths: 180/240/360 points Repro Create a new macOS App project named SidebarAnimationRepro, using SwiftUI and Swift. Set the deployment target to macOS 27.0. Replace SidebarAnimationReproApp.swift and ContentView.swift with the code below. Leave usesWorkaround set to false. Build and run. Keep the initial 906-point window width. Click Hide Sidebar and let the transition settle. Click Show Sidebar and watch the search field during expansion. Stop the app, change usesWorkaround to true, and run again. Repeat steps 4–5 to compare the behavior. Expected The split view should stay within the window during sidebar expansion. The search field should stay visible at its normal width without briefly collapsing or disappearing. Actual The split view temporarily grows to 1,146 points while the window stays 906 points wide. Search shrinks from 325 to 36 points and disappears, then returns to its normal size and visibility. The toolbar, search item, and search field remain the same instances, and toolbar item order doesn't change. In one capture, search collapsed about 123 ms after expansion started, returned at 274 ms, and the split view settled at 283 ms. With .useConstraints, the split view stayed at 906 points and search stayed visible at 325 points throughout both hide/show cycles. Screenshots Three frames before, during, and after the sidebar expansion: Sample Code SidebarAnimationReproApp.swift import SwiftUI @main struct SidebarAnimationReproApp: App { var body: some Scene { WindowGroup("Sidebar Animation Repro") { ContentView() } .defaultSize(width: 906, height: 600) } }ContentView.swift import AppKit import SwiftUI struct ContentView: View { @State private var searchText = "" var body: some View { NavigationSplitView { List { Label("Example", systemImage: "folder") } .navigationSplitViewColumnWidth(min: 180, ideal: 240, max: 360) } detail: { Text("Synthetic detail content") .frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity) .background { SplitViewAttachment() } .searchable(text: $searchText, placement: .toolbar) .toolbar { ToolbarSpacer(.flexible) DefaultToolbarItem(kind: .search) } } .toolbar(removing: .title) .frame(minWidth: 720, minHeight: 420) } } struct SplitViewAttachment: NSViewRepresentable { func makeNSView(context: Context) -> Attachment { Attachment() } func updateNSView(_ view: Attachment, context: Context) { view.applyWorkaround() } final class Attachment: NSView { private let usesWorkaround = false override func hitTest(_ point: NSPoint) -> NSView? { nil } override func viewDidMoveToWindow() { super.viewDidMoveToWindow() applyWorkaround() } /// The split controller can enter the responder chain after the view enters its window. override func layout() { super.layout() applyWorkaround() } fileprivate func applyWorkaround() { guard usesWorkaround, window != nil else { return } let responders = sequence(first: self as NSResponder, next: \.nextResponder) guard let controller = responders.first(where: { $0 is NSSplitViewController }) as? NSSplitViewController, let sidebar = controller.splitViewItems.first(where: { $0.behavior == .sidebar }), sidebar.collapseBehavior != .useConstraints else { return } sidebar.collapseBehavior = .useConstraints } } }
0
0
44
4d
@FocusedValue from .focusedSceneValue from the Scene Commands
Hi, In iPadOS can we use a .focusedSceneValue, defined from a command/Button inside a Scene, from inside the .command modifier attached to the scene? Like this: @main struct test_focusedSceneValueApp: App {     var body: some Scene {         WindowGroup {             ContentView()         }         .commands {             NavigationCommands()         }     } } struct NavigationCommands: Commands {     @FocusedValue(\.filterAction) var filterAction     var body: some Commands {         CommandMenu("Navigate") {             Button("Test focusedSceneValue") {                 filterAction?()             }             .keyboardShortcut("5")         }     } } struct ContentView: View {     @FocusState var isFiltering: Bool     @State private var focusField: String = "teste field teste"     var body: some View {         TextField("teste focus", text: $focusField)             .focused($isFiltering)             .focusedSceneValue(\.filterAction) {                 print("test successful")                 isFiltering = true             }     } This code is almost the same from the sample code from the documentation, however I can only retrieved nil values from the @FocusedValue and not the defined value. Thanks.
5
0
2.2k
5d
Article Accelerator tutorial: “Dissecting an app’s architecture” doesn’t explain data flow, and ArticleStore isn’t a realistic network simulation
Here's a sharper version. It's blunt about how badly the app is built, but it avoids swearing and insults, because forum moderators remove posts like that. Title: Article Accelerator: an architecture tutorial built on patterns we shouldn't copy Text: The tutorial "Dissecting an app's architecture" promises to show how data flows in and through Article Accelerator: https://developer.apple.com/tutorials/app-dev-training/dissecting-an-apps-architecture For a tutorial whose whole subject is architecture, the sample app is a poor example of it. The article never actually traces the data flow, and the code it describes uses patterns that most SwiftUI guidance tells you to avoid. The "simulated network service" isn't one. The tutorial says ArticleStore simulates a network service. In reality it's a singleton that synchronously loads JSON files from the bundle. It can't be slow, can't fail and can't return partial data, so it simulates none of what makes networking hard. It cannot be turned into an async URLSession call without throwing it away and redesigning the data layer. Views fetch data directly from a singleton. DetailView does private let articles = ArticleStore.shared.articles() as a stored property. There's no @Observable model, no loading state, no error state, and no dependency injection. This makes the views impossible to test with fake data and hides the data flow the tutorial claims to explain. Error handling is print and fatalError. A broken article file is silently skipped with print. An unreadable folder crashes the app. Failing to delete user data also crashes the app. SwiftData setup is inconsistent. The app creates one ModelContainer, then ArticleStateManager creates a separate ModelContext instead of using the container's mainContext. So writes through the manager and @Query reads go through different contexts. On top of that, the environment default for articleStateManager quietly creates a second ModelContainer with try!, so any window that forgets to inject it gets a different container. The structure isn't structured. The tutorial's challenge asks you to sort the Models folder into three categories, but the project puts everything in one flat folder, including ArticleStateManager, which isn't a model at all. Article, the main model, isn't even in it. The key design decision is never explained. Articles live only in memory while user data lives in SwiftData, and views join them by ID. That's a reasonable split, but the tutorial never says so, never explains why, and never addresses what it means for offline support, caching or paging. A learner who expects "fetch, store in SwiftData, show with @Query" is left confused. Official Apple tutorials are where many developers learn what good practice looks like. An article called "Dissecting an app's architecture" should either show a sound architecture, or clearly label the shortcuts as shortcuts. Right now it does neither. My questions: Is ArticleStore intended as a pattern to follow, or only a placeholder? What would Apple recommend for this app's data layer with a real async network service, including caching and paging?
0
0
158
6d
.bottomBar toolbar item missing after rotation in NavigationSplitView on iOS 26 (Regular width / compact height)
A ToolbarItem(placement: .bottomBar) inside a NavigationSplitView detail/destination view is missing after a device rotation on iOS 26. The bottom toolbar is missing until the view has been presented in both orientations, after which it renders correctly from then on. The issue does not reproduce on iOS 18. Environment iOS 26 only — does not reproduce on iOS 18 iPhone 17 Pro Max and iPhone 17 Air (i.e. devices that expose the landscape size class Regular width / compact height) SwiftUI NavigationSplitView with .balanced style Steps to reproduce Run the sample below on an iPhone 17 Pro Max or Air (or a simulator of either). Open the detail view (which contains a .bottomBar toolbar item) while the device is in either orientation. Rotate the device. Observe that the bottom toolbar is now missing. Expected behavior The .bottomBar button remains visible across rotation, regardless of which orientation the view was first presented in. Actual behavior On first presentation, rotating the device causes the bottom toolbar to disappear. Once the view has been presented in both landscape and portrait (roughly the third presentation), the bottom bar renders correctly and continues to behave correctly afterward. The behavior is inconsistent import SwiftUI @main struct MinimumReproducibleEventApp: App { var body: some Scene { WindowGroup { NavigationSplitView(columnVisibility: .constant(.all)) { NavigationLink("Primary") { ContentView() } } detail: { Text("Hello") } .navigationSplitViewStyle(.balanced) } } } ContentView import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .toolbar { ToolbarItem(placement: .bottomBar) { Button("Hello") { print("hello") } } } } }
Topic: UI Frameworks SubTopic: SwiftUI
7
2
593
6d
PhotosPicker selection badges initially appear blue, then change to the correct tint after backgrounding
Hello Apple Developer Team, I’m developing an iOS camera app called 1/250 using SwiftUI and the system photo picker (PhotosPicker). I’ve encountered an issue where the photo picker’s selection badge colors are inconsistent between the initial presentation and returning from the background. Steps to Reproduce 1. Open the app and present PhotosPicker. 2. Select multiple photos. 3. The numbered selection badges (1, 2, 3, etc.) appear in the default system blue, despite the app using yellow as its accent color. 4. Send the app to the background without dismissing PhotosPicker. 5. Return to the app. 6. The same selection badges now appear in the correct yellow color. Expected Behavior The numbered selection badges should use the app’s yellow tint color consistently, including when PhotosPicker is first presented. Actual Behavior * Initial presentation: Blue selection badges. * After backgrounding and returning: Yellow selection badges. * No changes to the selected photos or app settings are required. Questions 1. Is this a known issue with SwiftUI PhotosPicker or its underlying UIKit implementation? 2. Why would the tint color be applied correctly only after the app returns from the background? 3. Is there a recommended way to ensure the correct tint is applied before the picker is first displayed? 4. Is there an Apple-supported workaround that avoids recreating or replacing the system photo picker? I would prefer to continue using Apple’s native PhotosPicker rather than implementing a custom photo selection interface. Any guidance from Apple engineers would be greatly appreciated. Thank you!
Topic: UI Frameworks SubTopic: SwiftUI
0
0
134
6d
macOS 27 has a bit laggier menus than recent macOS versions. Can that be improved?
While not always too obvious there is sometimes delay or ”hiccup” when moving the arrow pointer horizontally among the menus for an app in top left of the menu bar. This feels like a regression from previous macOS versions. I hope this will improve in fuiture macOS 27 updates as it adds a bit of friction in the user interface experience. Wanted to add a video, but since only images seem supported to upload I might link to it later.
Topic: UI Frameworks SubTopic: General
1
0
101
6d
How to disable a custom detent in a UISheetPresentationController
If you are creating a UISheetPresentationController with custom detents and you have a need to disable one of the detents, then you can do so by returning a special value from the detent's resolver. This is addressed in the Objective-C documentation for customDetentWithIdentifier:resolver:. You return the special value UISheetPresentationControllerDetentInactive. For example: UISheetPresentationControllerDetent *customDetent = [UISheetPresentationControllerDetent customDetentWithIdentifier:@"customId" resolver:^CGFloat(id<UISheetPresentationControllerDetentResolutionContext> _Nonnull context) { if (some condition) { return UISheetPresentationControllerDetentInactive; } else { return context.maximumDetentValue / 3.0; } }];However, if you wish to do this in Swift, there is no corresponding API for UISheetPresentationControllerDetentInactive. It turns out that you can just use .greatestFiniteMagnitude instead. For example: let customDetent = UISheetPresentationController.Detent.custom(identifier: .init("customId")) { context in if some condition { return .greatestFiniteMagnitude //UISheetPresentationControllerDetentInactive } else { return context.maximumDetentValue / 3.0 } }It might be tempting to add the following: extension UISheetPresentationController.Detent { static let Inactive = CGFloat.greatestFiniteMagnitude }but this could cause a conflict if Apple adds a similar API in the future. This oversight in the Swift API has been reported as FB25567661.
1
0
119
6d
Button or onTapGesture grows its hit region by a fixed amount past the view’s bounds.
SwiftUI Button hit area extends ~16pt beyond its visual frame — expected OS behavior? Hi everyone, I’m working on a custom SwiftUI segmented control and noticed some unexpected hit-testing behavior with Button. I have a button structured roughly like this: Button { selectItem(at: index) } label: { ZStack { if selectedIndex == index { selectedBackground } SegmentCellView( tab: tab, isSelected: selectedIndex == index ) } .frame(maxWidth: .infinity) .contentShape(Rectangle()) } .accessibilityLabel(Text(tab.labelText)) The visual frame of the button has a certain height, but when testing on a real device, I can tap approximately 16pt outside the button's visible frame and the button still receives the tap. This seems to happen even though I explicitly use: .contentShape(Rectangle()) to define the tappable shape. My questions are: Is this ~16pt expansion of the interactive area expected SwiftUI/OS behavior? Is this related to Apple's minimum hit-target/accessibility guidelines being automatically applied to controls such as Button? If so, is there an official API/documentation describing this behavior? Is there a recommended way to make the Button's hit-testing area exactly match the bounds defined by .contentShape(Rectangle()), if that is actually possible? I'm particularly interested in understanding whether this is intentional system behavior or something caused by the ButtonStyle / layout hierarchy. Thanks!
2
1
148
6d
CPU spike when using RealityView in iOS
CPU spikes to over 100% and stays in that range when realityView (even without content) is added to an iOS view in SwiftUI. On device, it takes approximately 20 seconds before you see this behavior. How are developers getting around this in iOS apps? Is it getting past app review? Xcode 27.2, iOS27.2.1
0
0
78
6d
UIKIt, iOS 27, UIDocumentPickerViewController(forExporting: [fileURL])
My App saves files using the UIDocumentPickerViewController. This works from iOS 17 to 26. Usually, you have a file with a given name in your sandbox, which you can then export via the pickerVC. In the pickerVC you change the name. In iOS 27 the file name is greyed-out and you can't change it here. The file can be exported only with the pre-given name. Is this a new behaviour or bug in iOS 27?
Topic: UI Frameworks SubTopic: UIKit
2
0
166
1w
Can a complication/widget render a continuously animated custom graphic (watchOS)?
Can a complication/widget render a continuously animated custom graphic (watchOS)? I design abstract, number-free clock faces (see rhei.watch for examples — canvas-based, continuously animated) and I’m exploring whether something similar could work on Apple Watch. Since watchOS doesn’t allow fully custom third-party watch faces, I’m trying to understand what’s actually possible within the current constraints: Can a complication or widget render a continuously animated, custom canvas-style graphic — not just static icons/text/SF Symbols — similar to what’s possible with iOS lock screen widgets? Is there any path today for a third-party app to offer a watch-face-like experience, even without literally replacing the system face (e.g. via Smart Stack, a full-screen complication, Live Activities on watchOS, or something else I’m not aware of)? Any pointers to the right documentation, sample code, or past discussions would be really helpful before I invest time in building this. Thanks! Thomas
0
0
62
1w
Document-based app always opens untitled document even when a document is restored
If my NSDocument.canConcurrentlyReadDocuments(ofType:) implementation returns true, often when launching the app, an untitled document is created regardless whether another document is restored. If document reading is not concurrent, an untitled document is only created when no other document is restored, as expected. The issue happens on most app launches when a document is restored. If the restored document takes long to load (which can be simulated by putting sleep(1) in the Document.read(from:ofType:) implementation), the issue always happens. Is this expected, or is there a workaround? I created FB25340015.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
2
Boosts
0
Views
104
Activity
2d
UIDesignRequiresCompatibility = YES causes a crash on iOS 26 when built with Xcode 27. The key seems to follow the runtime OS, not the build SDK
Hi, I ran into a behavior of UIDesignRequiresCompatibility that doesn't match how I (and probably others) read the documentation. Environment Xcode: 27.2 Base SDK: iOS 27.2 Deployment target: iOS 18 Run destination: iOS 26.6 (physical device) Documentation The documentation states: "The system ignores this key when you build for iOS 27 or later, iPadOS 27 or later, Mac Catalyst 27 or later, macOS 27 or later, or tvOS 27 or later." I read "build for iOS 27" as a build-time condition: once the app is built with the iOS 27 SDK, the key no longer has any effect, whatever OS the app runs on. What I observed With UIDesignRequiresCompatibility = YES in Info.plist, I built the app against the iOS 27 SDK and ran it on iOS 26.6. The app crashes at launch. I removed only that key, did a clean build with the same configuration, and ran on the same iOS 26.6 device. The app runs normally. So in practice the key is not ignored for an app built for iOS 27. It looks like the decision is made by the OS the app runs on: iOS 27+ ignores the key, but iOS 26 still reads and applies it to a binary linked against the iOS 27 SDK, and that combination crashes. Questions What does "build for iOS 27 or later" refer to: the SDK the app is built with, the deployment target, or the OS the app runs on? My deployment target is iOS 18, so the app still runs on iOS 26. If the key is still honored there even when the app is built with the iOS 27 SDK, could the documentation say so explicitly? Is compatibility mode on iOS 26 for an app linked against the iOS 27 SDK an unsupported combination, and is the crash expected? Should developers simply remove the key when they adopt the iOS 27 SDK and still support iOS 26? Thanks!
Topic: UI Frameworks SubTopic: General Tags:
Replies
0
Boosts
0
Views
98
Activity
2d
iPhone Duo: Keep app on inner display while hinge is open (like Clock)?
I'm building a night-light app for iPhone Duo. When the device is partly open in tent mode, the lamp starts on the inner display. As soon as I set the phone down on a table, the system moves my window to the outer display, even though the hinge stays open. Apple's Clock app stays on the inner display in the same pose, so it seems possible at the system level. Steps Open iPhone Duo to ~80° (tent). Launch the app on the inner display. Set the device down on a table. Observed (logged from the app) UIHinge.status stays .partiallyOpen (~80°), not .closed. UIDevice.orientation goes portraitUpsideDown → faceDown → landscapeRight. UIScreen.didDisconnectNotification fires and UIScreen.screens drops the inner screen. The window moves to the outer screen (466×678). What I've tried Restricting UISupportedInterfaceOrientations to portrait only Turning on Rotation Lock Reading UIHingeInteraction (read-only, no effect on display routing) Looking at UISceneAccessory.cameraCapture, which only applies with an active capture session and a fully open device Question Is there a supported way for a scene to prefer or stay on the inner display while the hinge isn't closed? If not, I'll file a Feedback Assistant request. iPhone Duo · iOS 27.2 · Xcode 27.2
Topic: UI Frameworks SubTopic: SwiftUI
Replies
2
Boosts
0
Views
86
Activity
3d
iOS 27b3 SDK: iOS App on Mac crashes on UISearchBar focus
Our app crashes when compiled with the iOS 27 beta 3 SDK and run as an iOS app on Mac, on both macOS 26 and macOS 27, as soon as a UISearchBar receives focus. The crash is due to this exception: *** Assertion failure in BOOL _screenBasedFocusUnsupported(void)(), UIScreen.m:3.725 Accessing the focus system through UIScreen is no longer supported. ( 0 CoreFoundation 0x000000018bea31c0 __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018b91e91c objc_exception_throw + 88 2 Foundation 0x000000018e092644 -[NSMutableDictionary(NSMutableDictionary) initWithContentsOfFile:] + 0 3 UIKitCore 0x00000001c5dae8ec _screenBasedFocusUnsupported + 272 4 UIKitCore 0x00000001c5dae960 -[UIScreen _preferredFocusedWindow] + 24 5 UIKitCore 0x00000001c4ea3a60 -[UIScreen _mainSceneReferenceBounds] + 200 6 UIKitCore 0x00000001c4ea3914 -[UIScreen _mainSceneBoundsForInterfaceOrientation:] + 40 7 UIKitCore 0x00000001c5708134 +[UINavigationBar defaultSizeForOrientation:] + 76 8 UIKitCore 0x00000001c6222c88 -[_UISearchPresentationController _layoutPresentationWithSize:transitionCoordinator:] + 704 9 UIKitCore 0x00000001c622296c -[_UISearchPresentationController containerViewWillLayoutSubviews] + 84 10 UIKitCore 0x00000001c549304c block_destroy_helper.13 + 25112 11 UIKitCore 0x00000001c549344c block_destroy_helper.13 + 26136 12 UIKitCore 0x00000001c4ea26a8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1648 13 QuartzCore 0x0000000196103dbc _ZN2CA5Layer15perform_update_EPS0_P7CALayerjNS_17LayerUpdateReasonEPNS_11TransactionE + 460 14 QuartzCore 0x000000019610390c _ZN2CA5Layer17update_if_needed_EPNS_11TransactionENS_17LayerUpdateReasonE + 692 15 QuartzCore 0x0000000196035d2c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 608 16 QuartzCore 0x0000000195e69520 _ZN2CA11Transaction6commitEv + 652 17 AppKit 0x0000000190fe116c __37+[NSDisplayCycle currentDisplayCycle]_block_invoke.7 + 44 18 CoreFoundation 0x000000018be34ad0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28 19 CoreFoundation 0x000000018be34a10 __CFRunLoopDoBlocks + 396 20 CoreFoundation 0x000000018be33e54 __CFRunLoopRun + 2356 21 CoreFoundation 0x000000018bf06234 _CFRunLoopRunSpecificWithOptions + 532 22 HIToolbox 0x0000000198c1f560 RunCurrentEventLoopInMode + 320 23 HIToolbox 0x0000000198c228bc ReceiveNextEventCommon + 488 24 HIToolbox 0x0000000198dac14c _BlockUntilNextEventMatchingListInMode + 48 25 AppKit 0x00000001909163d0 _DPSBlockUntilNextEventMatchingListInMode + 228 26 AppKit 0x000000019026a084 _DPSNextEvent + 576 27 AppKit 0x0000000190dff96c -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 688 28 AppKit 0x0000000190dff678 -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:] + 72 29 AppKit 0x000000019025d13c -[NSApplication run] + 368 30 AppKit 0x00000001902357b0 NSApplicationMain + 880 31 AppKit 0x000000019047c958 +[NSWindow _savedFrameFromString:] + 0 32 UIKitMacHelper 0x00000001aa2651bc UINSApplicationMain + 972 33 UIKitCore 0x00000001c4e1aed4 UIApplicationMain + 144 34 UIKitCore 0x00000001c548bda0 block_destroy_helper.31 + 8880 35 DigitalConcertHall.debug.dylib 0x0000000106e41bd8 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 128 36 DigitalConcertHall.debug.dylib 0x0000000106e41b4c $s18DigitalConcertHall11AppDelegateC5$mainyyFZ + 32 37 DigitalConcertHall.debug.dylib 0x0000000106e4afc0 __debug_main_executable_dylib_entry_point + 28 38 dyld 0x000000018b9ac4e4 start + 6992 ) I could not test with the iOS 27 beta 4 SDK due to this blocking issue: https://developer.apple.com/forums/thread/839012 However, when I tried to set up a simple sample project, I could not reproduce the issue. Does anybody know what might be causing this? I filed feedback FB24201508
Replies
8
Boosts
2
Views
2k
Activity
3d
Keeping the display awake during hands-free auto-scroll in a watchOS reading app
I develop Folito, a free watchOS app for reading EPUB books on Apple Watch. We added an auto-scroll mode: the text scrolls continuously at a speed the user sets with the Digital Crown, so they can read hands-free with their wrist raised. The display dims after the wake timeout because auto-scroll isn't user interaction, so the text becomes hard to read after 15–70 seconds while the user is still reading. What we've considered Pausing on isLuminanceReduced and resuming on tap. This works, but it needs a touch every minute. Continuing in Always On (luminance reduced) with ~1 Hz line-by-line updates. This is our current plan, but the text is dimmed and SE models have no Always On. WKExtendedRuntimeSession. None of the session types (self care, mindfulness, physical therapy, smart alarm, workout) describes reading, and we don't want to misuse one. HKWorkoutSession. Not appropriate, because it would record fake workouts. Questions Is there a supported way for a frontmost app to keep the display at normal brightness while showing continuously changing content the user is reading, without touch input? Would a WKExtendedRuntimeSession started only while auto-scroll runs (and ended as soon as it pauses or stops) be acceptable for this, and if so, which type? In Always On, what's the recommended way to keep text content advancing (for example, updating a ScrollView position via ScrollViewReader about once per second)? I found thread 720495 (iOS, isIdleTimerDisabled) and thread 122753 (Always On, 2019), but neither covers a watchOS app that needs the display awake while content advances on its own. Deployment target: watchOS 10, SwiftUI. Thanks!
Replies
1
Boosts
0
Views
263
Activity
3d
UIWindowScene sizeRestrictions minimumSize not working on iPadOS
Hello, following Apple docs and guidance from WWDC I'm trying to set a minimum size for my scene, for example I want it to minimally be 3/4 the width and height of the device. I've removed the UIRequiresFullScreen Info.plist property. The app does run in windowed mode and does have a resizing handle. I've implemented this UISceneDelegate: var window: UIWindow? var cameraWindow: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { window = UIWindow(windowScene: scene as! UIWindowScene) // setup root view controller let rootViewController: MainViewController = MainViewController(nibName: "Main", bundle: nil) let navController: NavigationController = NavigationController(rootViewController: rootViewController) navController.modalPresentationStyle = .fullScreen // set reasonable minimum sizes for WindowScene if let windowScene: UIWindowScene = scene as? UIWindowScene { if #available(iOS 16.0, *) { let windowSize: CGSize = windowScene.coordinateSpace.bounds.size windowScene.sizeRestrictions?.minimumSize.width = windowSize.width * 0.75 windowScene.sizeRestrictions?.minimumSize.height = windowSize.height * 0.75 } } window?.rootViewController = navController window?.makeKeyAndVisible() } } And proven via debugger that this code is being executed. I have the following observations: After setting these minimumSize properties I see the width and height both contain 0 afterwards, as if the property settings are discarding the value. I've even used hard-coded values instead of reading the coordinateSpace.bounds, to no avail. The scene is allowing resizing well below these minimums, about 1/3 the width and 1/2 the height. Anyone else observed this and have suggestions?
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
1
Views
370
Activity
3d
Using SF Symbols with a changed global locale
When changing the global locale by std::locale::global(std::locale(NAME)) where NAME is a valid and supported name of a locale all access using [UIImage systemImageNamed:@"..."] fails. Is there a way to modify the global locale and still have access to the SF Symbols?
Replies
2
Boosts
0
Views
256
Activity
3d
Can I use a template image for quick actions?
Hey Team, System-provided quick actions in Finder sport a template image that adapts correctly to light and dark modes. However when I add a quick action extension in my app, the icon I refer to in the Info.plist renders in full color, even if it is defined in the asset catalog as a template image. This forces me to either use my app icon or a gray icon that will work in either appearance. How can I get the system-provided quick actions treatment? Thanks, Ari
Topic: UI Frameworks SubTopic: AppKit
Replies
2
Boosts
1
Views
320
Activity
4d
NavigationSplitView sidebar expansion temporarily oversizes split view and collapses toolbar search
[Submitted as FB25597038] Showing the sidebar in a two-column NavigationSplitView briefly collapses the toolbar search field, even though the window doesn't resize. Search is right-aligned on the detail container using .searchable, ToolbarSpacer(.flexible), and DefaultToolbarItem(kind: .search). The sample below uses static content and the native sidebar toggle and animation. Setting only the sidebar item's collapseBehavior to .useConstraints avoids the issue. It occurred in both recorded baseline expansions and neither expansion with the workaround. Environment macOS 27.2.1 (26B131) Xcode 27.2 (27B52) macOS SDK 27.2 (26B118) Native macOS app, arm64, deployment target macOS 27.0 Initial window: 906 × 600 points Sidebar minimum/ideal/maximum widths: 180/240/360 points Repro Create a new macOS App project named SidebarAnimationRepro, using SwiftUI and Swift. Set the deployment target to macOS 27.0. Replace SidebarAnimationReproApp.swift and ContentView.swift with the code below. Leave usesWorkaround set to false. Build and run. Keep the initial 906-point window width. Click Hide Sidebar and let the transition settle. Click Show Sidebar and watch the search field during expansion. Stop the app, change usesWorkaround to true, and run again. Repeat steps 4–5 to compare the behavior. Expected The split view should stay within the window during sidebar expansion. The search field should stay visible at its normal width without briefly collapsing or disappearing. Actual The split view temporarily grows to 1,146 points while the window stays 906 points wide. Search shrinks from 325 to 36 points and disappears, then returns to its normal size and visibility. The toolbar, search item, and search field remain the same instances, and toolbar item order doesn't change. In one capture, search collapsed about 123 ms after expansion started, returned at 274 ms, and the split view settled at 283 ms. With .useConstraints, the split view stayed at 906 points and search stayed visible at 325 points throughout both hide/show cycles. Screenshots Three frames before, during, and after the sidebar expansion: Sample Code SidebarAnimationReproApp.swift import SwiftUI @main struct SidebarAnimationReproApp: App { var body: some Scene { WindowGroup("Sidebar Animation Repro") { ContentView() } .defaultSize(width: 906, height: 600) } }ContentView.swift import AppKit import SwiftUI struct ContentView: View { @State private var searchText = "" var body: some View { NavigationSplitView { List { Label("Example", systemImage: "folder") } .navigationSplitViewColumnWidth(min: 180, ideal: 240, max: 360) } detail: { Text("Synthetic detail content") .frame(minWidth: 0, maxWidth: .infinity, maxHeight: .infinity) .background { SplitViewAttachment() } .searchable(text: $searchText, placement: .toolbar) .toolbar { ToolbarSpacer(.flexible) DefaultToolbarItem(kind: .search) } } .toolbar(removing: .title) .frame(minWidth: 720, minHeight: 420) } } struct SplitViewAttachment: NSViewRepresentable { func makeNSView(context: Context) -> Attachment { Attachment() } func updateNSView(_ view: Attachment, context: Context) { view.applyWorkaround() } final class Attachment: NSView { private let usesWorkaround = false override func hitTest(_ point: NSPoint) -> NSView? { nil } override func viewDidMoveToWindow() { super.viewDidMoveToWindow() applyWorkaround() } /// The split controller can enter the responder chain after the view enters its window. override func layout() { super.layout() applyWorkaround() } fileprivate func applyWorkaround() { guard usesWorkaround, window != nil else { return } let responders = sequence(first: self as NSResponder, next: \.nextResponder) guard let controller = responders.first(where: { $0 is NSSplitViewController }) as? NSSplitViewController, let sidebar = controller.splitViewItems.first(where: { $0.behavior == .sidebar }), sidebar.collapseBehavior != .useConstraints else { return } sidebar.collapseBehavior = .useConstraints } } }
Replies
0
Boosts
0
Views
44
Activity
4d
@FocusedValue from .focusedSceneValue from the Scene Commands
Hi, In iPadOS can we use a .focusedSceneValue, defined from a command/Button inside a Scene, from inside the .command modifier attached to the scene? Like this: @main struct test_focusedSceneValueApp: App {     var body: some Scene {         WindowGroup {             ContentView()         }         .commands {             NavigationCommands()         }     } } struct NavigationCommands: Commands {     @FocusedValue(\.filterAction) var filterAction     var body: some Commands {         CommandMenu("Navigate") {             Button("Test focusedSceneValue") {                 filterAction?()             }             .keyboardShortcut("5")         }     } } struct ContentView: View {     @FocusState var isFiltering: Bool     @State private var focusField: String = "teste field teste"     var body: some View {         TextField("teste focus", text: $focusField)             .focused($isFiltering)             .focusedSceneValue(\.filterAction) {                 print("test successful")                 isFiltering = true             }     } This code is almost the same from the sample code from the documentation, however I can only retrieved nil values from the @FocusedValue and not the defined value. Thanks.
Replies
5
Boosts
0
Views
2.2k
Activity
5d
Article Accelerator tutorial: “Dissecting an app’s architecture” doesn’t explain data flow, and ArticleStore isn’t a realistic network simulation
Here's a sharper version. It's blunt about how badly the app is built, but it avoids swearing and insults, because forum moderators remove posts like that. Title: Article Accelerator: an architecture tutorial built on patterns we shouldn't copy Text: The tutorial "Dissecting an app's architecture" promises to show how data flows in and through Article Accelerator: https://developer.apple.com/tutorials/app-dev-training/dissecting-an-apps-architecture For a tutorial whose whole subject is architecture, the sample app is a poor example of it. The article never actually traces the data flow, and the code it describes uses patterns that most SwiftUI guidance tells you to avoid. The "simulated network service" isn't one. The tutorial says ArticleStore simulates a network service. In reality it's a singleton that synchronously loads JSON files from the bundle. It can't be slow, can't fail and can't return partial data, so it simulates none of what makes networking hard. It cannot be turned into an async URLSession call without throwing it away and redesigning the data layer. Views fetch data directly from a singleton. DetailView does private let articles = ArticleStore.shared.articles() as a stored property. There's no @Observable model, no loading state, no error state, and no dependency injection. This makes the views impossible to test with fake data and hides the data flow the tutorial claims to explain. Error handling is print and fatalError. A broken article file is silently skipped with print. An unreadable folder crashes the app. Failing to delete user data also crashes the app. SwiftData setup is inconsistent. The app creates one ModelContainer, then ArticleStateManager creates a separate ModelContext instead of using the container's mainContext. So writes through the manager and @Query reads go through different contexts. On top of that, the environment default for articleStateManager quietly creates a second ModelContainer with try!, so any window that forgets to inject it gets a different container. The structure isn't structured. The tutorial's challenge asks you to sort the Models folder into three categories, but the project puts everything in one flat folder, including ArticleStateManager, which isn't a model at all. Article, the main model, isn't even in it. The key design decision is never explained. Articles live only in memory while user data lives in SwiftData, and views join them by ID. That's a reasonable split, but the tutorial never says so, never explains why, and never addresses what it means for offline support, caching or paging. A learner who expects "fetch, store in SwiftData, show with @Query" is left confused. Official Apple tutorials are where many developers learn what good practice looks like. An article called "Dissecting an app's architecture" should either show a sound architecture, or clearly label the shortcuts as shortcuts. Right now it does neither. My questions: Is ArticleStore intended as a pattern to follow, or only a placeholder? What would Apple recommend for this app's data layer with a real async network service, including caching and paging?
Replies
0
Boosts
0
Views
158
Activity
6d
.bottomBar toolbar item missing after rotation in NavigationSplitView on iOS 26 (Regular width / compact height)
A ToolbarItem(placement: .bottomBar) inside a NavigationSplitView detail/destination view is missing after a device rotation on iOS 26. The bottom toolbar is missing until the view has been presented in both orientations, after which it renders correctly from then on. The issue does not reproduce on iOS 18. Environment iOS 26 only — does not reproduce on iOS 18 iPhone 17 Pro Max and iPhone 17 Air (i.e. devices that expose the landscape size class Regular width / compact height) SwiftUI NavigationSplitView with .balanced style Steps to reproduce Run the sample below on an iPhone 17 Pro Max or Air (or a simulator of either). Open the detail view (which contains a .bottomBar toolbar item) while the device is in either orientation. Rotate the device. Observe that the bottom toolbar is now missing. Expected behavior The .bottomBar button remains visible across rotation, regardless of which orientation the view was first presented in. Actual behavior On first presentation, rotating the device causes the bottom toolbar to disappear. Once the view has been presented in both landscape and portrait (roughly the third presentation), the bottom bar renders correctly and continues to behave correctly afterward. The behavior is inconsistent import SwiftUI @main struct MinimumReproducibleEventApp: App { var body: some Scene { WindowGroup { NavigationSplitView(columnVisibility: .constant(.all)) { NavigationLink("Primary") { ContentView() } } detail: { Text("Hello") } .navigationSplitViewStyle(.balanced) } } } ContentView import SwiftUI struct ContentView: View { var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Hello, world!") } .toolbar { ToolbarItem(placement: .bottomBar) { Button("Hello") { print("hello") } } } } }
Topic: UI Frameworks SubTopic: SwiftUI
Replies
7
Boosts
2
Views
593
Activity
6d
PhotosPicker selection badges initially appear blue, then change to the correct tint after backgrounding
Hello Apple Developer Team, I’m developing an iOS camera app called 1/250 using SwiftUI and the system photo picker (PhotosPicker). I’ve encountered an issue where the photo picker’s selection badge colors are inconsistent between the initial presentation and returning from the background. Steps to Reproduce 1. Open the app and present PhotosPicker. 2. Select multiple photos. 3. The numbered selection badges (1, 2, 3, etc.) appear in the default system blue, despite the app using yellow as its accent color. 4. Send the app to the background without dismissing PhotosPicker. 5. Return to the app. 6. The same selection badges now appear in the correct yellow color. Expected Behavior The numbered selection badges should use the app’s yellow tint color consistently, including when PhotosPicker is first presented. Actual Behavior * Initial presentation: Blue selection badges. * After backgrounding and returning: Yellow selection badges. * No changes to the selected photos or app settings are required. Questions 1. Is this a known issue with SwiftUI PhotosPicker or its underlying UIKit implementation? 2. Why would the tint color be applied correctly only after the app returns from the background? 3. Is there a recommended way to ensure the correct tint is applied before the picker is first displayed? 4. Is there an Apple-supported workaround that avoids recreating or replacing the system photo picker? I would prefer to continue using Apple’s native PhotosPicker rather than implementing a custom photo selection interface. Any guidance from Apple engineers would be greatly appreciated. Thank you!
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
134
Activity
6d
macOS 27 has a bit laggier menus than recent macOS versions. Can that be improved?
While not always too obvious there is sometimes delay or ”hiccup” when moving the arrow pointer horizontally among the menus for an app in top left of the menu bar. This feels like a regression from previous macOS versions. I hope this will improve in fuiture macOS 27 updates as it adds a bit of friction in the user interface experience. Wanted to add a video, but since only images seem supported to upload I might link to it later.
Topic: UI Frameworks SubTopic: General
Replies
1
Boosts
0
Views
101
Activity
6d
How to disable a custom detent in a UISheetPresentationController
If you are creating a UISheetPresentationController with custom detents and you have a need to disable one of the detents, then you can do so by returning a special value from the detent's resolver. This is addressed in the Objective-C documentation for customDetentWithIdentifier:resolver:. You return the special value UISheetPresentationControllerDetentInactive. For example: UISheetPresentationControllerDetent *customDetent = [UISheetPresentationControllerDetent customDetentWithIdentifier:@"customId" resolver:^CGFloat(id<UISheetPresentationControllerDetentResolutionContext> _Nonnull context) { if (some condition) { return UISheetPresentationControllerDetentInactive; } else { return context.maximumDetentValue / 3.0; } }];However, if you wish to do this in Swift, there is no corresponding API for UISheetPresentationControllerDetentInactive. It turns out that you can just use .greatestFiniteMagnitude instead. For example: let customDetent = UISheetPresentationController.Detent.custom(identifier: .init("customId")) { context in if some condition { return .greatestFiniteMagnitude //UISheetPresentationControllerDetentInactive } else { return context.maximumDetentValue / 3.0 } }It might be tempting to add the following: extension UISheetPresentationController.Detent { static let Inactive = CGFloat.greatestFiniteMagnitude }but this could cause a conflict if Apple adds a similar API in the future. This oversight in the Swift API has been reported as FB25567661.
Replies
1
Boosts
0
Views
119
Activity
6d
Button or onTapGesture grows its hit region by a fixed amount past the view’s bounds.
SwiftUI Button hit area extends ~16pt beyond its visual frame — expected OS behavior? Hi everyone, I’m working on a custom SwiftUI segmented control and noticed some unexpected hit-testing behavior with Button. I have a button structured roughly like this: Button { selectItem(at: index) } label: { ZStack { if selectedIndex == index { selectedBackground } SegmentCellView( tab: tab, isSelected: selectedIndex == index ) } .frame(maxWidth: .infinity) .contentShape(Rectangle()) } .accessibilityLabel(Text(tab.labelText)) The visual frame of the button has a certain height, but when testing on a real device, I can tap approximately 16pt outside the button's visible frame and the button still receives the tap. This seems to happen even though I explicitly use: .contentShape(Rectangle()) to define the tappable shape. My questions are: Is this ~16pt expansion of the interactive area expected SwiftUI/OS behavior? Is this related to Apple's minimum hit-target/accessibility guidelines being automatically applied to controls such as Button? If so, is there an official API/documentation describing this behavior? Is there a recommended way to make the Button's hit-testing area exactly match the bounds defined by .contentShape(Rectangle()), if that is actually possible? I'm particularly interested in understanding whether this is intentional system behavior or something caused by the ButtonStyle / layout hierarchy. Thanks!
Replies
2
Boosts
1
Views
148
Activity
6d
CPU spike when using RealityView in iOS
CPU spikes to over 100% and stays in that range when realityView (even without content) is added to an iOS view in SwiftUI. On device, it takes approximately 20 seconds before you see this behavior. How are developers getting around this in iOS apps? Is it getting past app review? Xcode 27.2, iOS27.2.1
Replies
0
Boosts
0
Views
78
Activity
6d
UIKIt, iOS 27, UIDocumentPickerViewController(forExporting: [fileURL])
My App saves files using the UIDocumentPickerViewController. This works from iOS 17 to 26. Usually, you have a file with a given name in your sandbox, which you can then export via the pickerVC. In the pickerVC you change the name. In iOS 27 the file name is greyed-out and you can't change it here. The file can be exported only with the pre-given name. Is this a new behaviour or bug in iOS 27?
Topic: UI Frameworks SubTopic: UIKit
Replies
2
Boosts
0
Views
166
Activity
1w
Can a complication/widget render a continuously animated custom graphic (watchOS)?
Can a complication/widget render a continuously animated custom graphic (watchOS)? I design abstract, number-free clock faces (see rhei.watch for examples — canvas-based, continuously animated) and I’m exploring whether something similar could work on Apple Watch. Since watchOS doesn’t allow fully custom third-party watch faces, I’m trying to understand what’s actually possible within the current constraints: Can a complication or widget render a continuously animated, custom canvas-style graphic — not just static icons/text/SF Symbols — similar to what’s possible with iOS lock screen widgets? Is there any path today for a third-party app to offer a watch-face-like experience, even without literally replacing the system face (e.g. via Smart Stack, a full-screen complication, Live Activities on watchOS, or something else I’m not aware of)? Any pointers to the right documentation, sample code, or past discussions would be really helpful before I invest time in building this. Thanks! Thomas
Replies
0
Boosts
0
Views
62
Activity
1w