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

Enabling Show Tab Bar Programmatically
I have a macOS application developed in SwiftUI. It's a document-based application. I know how to hide the Show Tab Bar command under View. I don't want to hide it. I always want to show tabs. I wonder how to enable this command programmatically such that the document window always has the + button to the right. Thanks.
0
0
119
May ’25
NavigationPath.append but .navigationDestination Not Being Called
I am trying to do a bit of fancy navigation in SwiftUI using NavigationPath and am having a problem. I have a root view with includes a button: struct ClassListScreen: View { @Bindable private var router = AppRouter.shared @State private var addCourse: Bool = false ... var body: some View { ... Button("Add Class") { router.currentPath.append(addCourse) }.buttonStyle(.borderedProminent) ... .navigationDestination(for: Bool.self){ _ in ClassAddDialog { course in sortCourses() } } } } router.currentPath is the NavigationPath associated with the operative NavigationStack. (This app has a TabView and each Tab has its own NavigationStack and NavigationPath). Tapping the button correctly opens the ClassAddDialog. In ClassAddDialog is another button: struct ClassAddDialog: View { @Bindable private var router = AppRouter.shared @State private var idString: String = "" ... var body: some View { ... Button("Save") { let course = ... ... (save logic) idString = course.id.uuidString var path = router.currentPath path.removeLast() path.append(idString) router.currentPath = path }.buttonStyle(.borderedProminent) ... .navigationDestination(for: String.self) { str in if let id = UUID(uuidString: str), let course = Course.findByID(id, with: context) { ClassDetailScreen(course: course) } } } } My intent here is that tapping the Save button in ClassAddDialog would pop that view and move directly to the ClassDetailScreen (without returning to the root ClassListScreen). The problem is that the code inside the navigationDestination is NEVER hit. (I.e., a breakpoint on the if let ... statement) never fires. I just end up on a (nearly) blank view with a warning triangle icon in its center. (And yes, the back button takes me to the root, so the ClassAddDialog WAS removed as expected.) And I don't understand why. Can anyone share any insight here?
0
1
105
Oct ’25
Zoom navigation causes the source view to disappear
After returning from the child view to the parent, the latter one will simply disappear. This is the full view. See itemsContent where I perform the navigation. The last tapped rectangle in this example will simply disappear. struct DashboardView: View { @State var viewModel: DahsboardViewModel @Namespace private var namespace var body: some View { ScrollView(.vertical) { LazyVStack(spacing: 24) { ForEach(viewModel.sections) { section in VStack(spacing: 16) { Text(section.title) itemsContent(for: section) } } } } } func itemsContent(for section: DashboardSection) -> some View { ForEach(section.items) { item in NavigationLink { PatternLearningRouter().rootView .id(item.id) .navigationTransition(.zoom(sourceID: item.id, in: namespace)) } label: { Rectangle() .fill(Color.yellow) .frame(width: 80, height: 80) .overlay { Text(item.title) } .matchedTransitionSource(id: item.id, in: namespace) } } } } XCode26 26.0.1(17A400) iPhone 16 Pro, iOS 26.0.1 Note: Only reproduced when I swipe back (not reproducing it when using back button) Only reproduced on real device not simulator I
0
1
84
Oct ’25
When is the StateObject’s autoclosure actually called?
The signature of the StateObject initializer is init(wrappedValue thunk: @autoclosure @escaping () -> ObjectType). The fact that the autoclosure is marked as escaping intrigues me, because that suggests that it could be called after the init has returned. Why this is interesting is because I have some code where the viewmodel given to the @StateObject depends on an implicitly unwrapped optional type, and I expect the top level initialization of the StateObject to crash because the implicitly unwrapped optional is not ready yet, but to my surprise it did not. My theory is that the autoclosure is being called after the View’s initialization had been called, when the dependency is ready. heres a minimal sample of that. class MyDependency: ObservableObject { @Published var value = "Hello" } class MyViewModel: ObservableObject { let dependency: MyDependency init(dependency: MyDependency = TestApp.dependency) { self.dependency = dependency print("✅ ViewModel initialized with dependency:", dependency.value) } } struct ContentView: View { @StateObject private var viewModel = MyViewModel() // ⚠️ expected crash? var body: some View { Text(viewModel.dependency.value).onAppear { TestApp.dependency = Dependency()// dependency is set here after init has been called } } } @main struct TestApp: App { static var dependency: MyDependency! // not ready yet var body: some Scene { WindowGroup { ContentView() } }```
0
0
135
Oct ’25
Document-based app: file picker flickers since macOS 26 update
Description: Since updating to Tahoe, the file picker dialog briefly flickers immediately after opening in my document-based app. This behavior did not occur on macOS Sequoia. Rhe issue does not appear in TextEdit, but it does occur in Paper (a writing app) and Kaleidoscope. Based on this, it seems to affect third-party document-based apps that use standard open panels. Steps to Reproduce: 1. Launch a third-party document-based app. 2. Open the file picker (e.g., via “Open…”). 3. Observe a brief flicker as the dialog appears. Expected Result: The file picker dialog should open smoothly without flickering. Actual Result: The file picker dialog flickers briefly right after appearing. Notes: • Issue introduced in macOS Tahoe. • Not reproducible in macOS Sequoia. Reported through Feedback Assistant: FB20522119
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
150
Oct ’25
Unknown error when displaying IntentItems with images in widget configuration intent
Hi everyone, I’m building a simple sticky notes app that allows users to place a note widget on their home screen. Each widget displays a user-created sticky note. To let users choose which note to show, I’ve implemented an Intent that presents a list of existing sticky notes. The list is built using IntentItems, and for each item I assign an image to visually represent the note. Each sticky note can have a different background color and optional image, so I generate a small PNG (150×150, ~30 KB) and include it in the app bundle. However, when I try to display the selection list, I get the following error: The action Select sticky note could not run because an unknown error occurred. If I tap OK and try again, the intent selector appears and works. Here’s what I’d like to understand: What could cause this unknown error when using images in IntentItems? Are there known limitations on image size, source, or format for intent item images? Can I supply a unique image per sticky note, or must all intent items share a common image? Any guidance or insights would be greatly appreciated — I haven’t been able to find clear documentation about image handling in IntentItem for widget configuration. Thanks!
0
0
112
Oct ’25
Bottom toolbar Button truncated on Mac Catalyst 26
On Mac Catalyst 26, a Button bar item in a bottom toolbar look squished. This happens only when the "Mac Catalyst Interface" option is set to "Optimize for Mac". When it is set to "Scale to match iPad", the buttons look fine. For example, in the screenshots below, the text button should say "Press Me", instead of "…" A simple reproducible snippet and a screenshot below. The toolbar button comparison between "Scale to match iPad" and "Optimize for Mac" are shown. Optimize for Mac Scale to match iPad import SwiftUI struct ContentView: View { @State private var selectedItem: String? = "Item 1" let items = ["Item 1", "Item 2"] var body: some View { NavigationSplitView { List(items, id: \.self, selection: $selectedItem) { item in Text(item) } .navigationTitle("Items") } detail: { if let selectedItem = selectedItem { Text("Detail view for \(selectedItem)") .toolbar { ToolbarItemGroup(placement: .bottomBar) { Text("Hello world") Spacer() Button("Press Me") { } Spacer() Button { } label: { Image(systemName: "plus") .imageScale(.large) } } } } else { Text("Select an item") } } } }
0
1
281
Oct ’25
ToolbarItems under tabView BottomBar on iOS26
The iOS with TabView places the .bottomBar toolbar items under the TabView items and does not raise them on top of them. iPadOS (when resized to a smaller width where the TabView places to the bottomBar) and previous iOS18 on iOS and iPadOS works correctly. Reported (FB20447249)
Topic: UI Frameworks SubTopic: SwiftUI
0
1
74
Sep ’25
How to detect modifier keys with hardware keyboard in SwiftUI (iOS)?
Hi everyone, In UIKit, I can detect which key and modifier keys are pressed from an external hardware keyboard using the pressesBegan method in a UIResponder: override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) { for press in presses { if let key = press.key { print("Key: \(key.charactersIgnoringModifiers ?? "")") print("Modifiers: \(key.modifierFlags)") } } } I am now working in SwiftUI (iOS), and I couldn’t find a direct equivalent for pressesBegan. What is the recommended way in SwiftUI to detect modifier keys + key presses from an external keyboard? Is there a built-in API, or should I always wrap a UIKit view/controller for this purpose? Thanks in advance!
0
0
72
Sep ’25
SwiftUI: Can a NavigationDestination in NavigationStack present the view as a .sheet instead of pushing?
Hi everyone, I’m experimenting with SwiftUI's new NavigationStack / navigationDestination API. Normally, when you navigate to a value using NavigationLink(value:) and a matching navigationDestination(for:), the destination view is pushed onto the navigation stack. What I’d like to know is: Is there a way to present that destination view as a sheet instead of pushing it? Essentially: Can a NavigationDestination be shown modally? Here’s a simplified example of what I mean: struct RootView: View { var body: some View { NavigationStack { NavigationLink(value: "Example") { Text("Push me!") } .navigationDestination(for: String.self) { _ in DetailView() // <--- Can this be shown as a sheet? } } } } My questions are: Is there a built‑in way to make a navigationDestination present modally (as .sheet) instead of pushing? If not, is the recommended approach to handle .sheet state manually outside of the NavigationStack and bypass navigationDestination for such cases? Can the NavigationPath itself somehow encode a modal presentation style for certain types? Thanks in advance for any tips or confirmation that this is (not) possible in SwiftUI.
0
0
109
Sep ’25
How to apply SwiftUI window modifiers when using Xcode's #Preview on a macOS view?
Is there a way to configure the style and toolbar of the macOS window that Xcode uses in #Preview? I am working on a macOS application and want to preview some SwiftUI views within different window styles, toolbar styles and window title/subtitle visibilities. Some of the modifiers to control the look-and-feel of a window are actually Scene Modifiers, not View Modifiers: .windowStyle .windowToolbarLabelStyle .windowToolbarStyle But #Preview does not accept Scenes, so I can't apply these modifiers: // Error, not a view modifier. #Preview { ContentView() .windowStyle(...) } // Error, Window is not supported in #Preview. #Preview { Window("Browser", id: "browser") { ContentView() } } If I give my ContentView a .toolbar(...), Xcode's Preview will correctly show a window with a toolbar, but not necessarily in the style I want. Is there a way to apply the Scene Modifiers to #Preview so that I can see how they affect the window's chrome and toolbar?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
1
84
Oct ’25
SwiftUI Glyphs clipped, how do I show the entire glyph?
This code: import SwiftUI struct heightProblem: View { var body: some View { Text("\u{1D15E} \u{1D15F} \u{1D160} \u{1D161} \u{1D162} \u{1D163} \u{1D164}") .font(Font.largeTitle.bold()) .frame(height: 50.0) .border(.red) .padding() .border(.green) } } #Preview { heightProblem() } Produces this display: Note the clipping. Lowering the baseline by about 20 brings it into view, but this is a horrible fix for dynamic display (The font is Noto, which works just fine in Xcode, but not in Safari for some reason.)
0
0
122
Sep ’25
SwiftUI TextField with lineLimit inside Form does not respect lineLimit.
macos 26, xcode 26, ios 26. Everytime when you add new line at some point (like after 10-20 lines) the TextField will ignore the lineLimit and start changing the height. The problem related to Form but not Scroll. Maybe it can be reproduced in other scroll-based views. Bug report opened. Any siggestions? struct Test: View { @State var text = "" var body: some View { Form { Section { TextField("", text: $text, axis: .vertical) .lineLimit(3) .background(Color.green) } } } } @main struct TestApp: App { var body: some Scene { WindowGroup { Test() } } }
0
0
76
Sep ’25
timeline method is not being called for AppIntentTimelineProvider implementation on iOS 17 only
I have a widget that runs well on iOS 18. It is configurable and implements AppIntentTimelineProvider on the Provider. On iOS 17 it will call the placeholder method 7 times and not call the timeline method. The configuration intent implements WidgetConfigurationIntent. I've looked through the console logs and saw "ApplicationExtension record not found" but I'm not sure where to go from there. Why would the same widget work fine on iOS 18 and not 17? If I implement TimelineProvider and use a StaticConfiguration it works on iOS 17. Any help / guidance would be appreciated.
0
0
120
Jun ’25
Showing space .navigationTitle leads to unexpected results.
I wanted to set navigationTitle value to space symbol on my iOS app (Swift 6, iOS 26.0) (so that navigationBar opens in large mode initially before the actual value is being fetched). In my view I used this: .navigationTitle(" ") And on device I got unexpectedly two quote symbols: Not sure if there is space in between, and the symbols look like opening and closing quote (both quotes in code I think are the same symbols) - so probably it's not part of my code is visible in UI as one might think... . Is this a bug? Or undocumented feature?
0
1
124
Sep ’25
tvOS 26 Top shelf's playbackProgress is broken
Here is a minimal code private func createItem(from movie: Movie, showProgress: Bool, imageType: ImageType) -> TVTopShelfSectionedItem { let item = TVTopShelfSectionedItem(identifier: movie.id) // Set title for the item item.title = movie.title switch imageType { case .landscape: item.imageShape = .hdtv // HDTV shape for landscape/backdrop images if let backdropUrl = movie.backdropUrl, let url = URL(string: backdropUrl) { item.setImageURL(url, for: .screenScale2x) } case .poster: item.imageShape = .poster // Poster shape for poster images if let posterUrl = movie.posterUrl, let url = URL(string: posterUrl) { item.setImageURL(url, for: .screenScale2x) } } if showProgress { item.playbackProgress = 0.5 } return item } As you can see the progress bar is pushed to the bottom. There is no padding around it. Am I doing something wrong or this is bug in the framework?
0
0
220
Sep ’25
Open file directly into editor view with DocumentGroup
This was also raised in FB17028569 I have iOS document based app using DocumentGroup. I can create and save documents as expected. All that functionality is fine. @main struct FooBarApp: App { var body: some Scene { DocumentGroup(newDocument: { FoobarDocument() }) { config in MainView(document: config.document) } The problem is when I open an app document from Files.app or Messages the document is never opened directly into the editor, the document browser interface is always presented and the user must manually select the document to open an editor. This also happens when I use UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil) to open a new scene. The doc isn't opened into my editor. I believe my plist document types are setup correctly and that my ReferenceFileDocument is setup correctly <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeExtensions</key> <array> <string>foobar</string> </array> <key>CFBundleTypeIconFile</key> <string>icon-128</string> <key>CFBundleTypeIconSystemGenerated</key> <integer>1</integer> <key>CFBundleTypeMIMETypes</key> <array> <string>application/json</string> </array> <key>CFBundleTypeName</key> <string>Foobar Project</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.digital-dirtbag.foobar</string> </array> <key>NSUbiquitousDocumentUserActivityType</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).ubiquitousdoc</string> </dict> </array> <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>Foobar Project</string> <key>UTTypeIconFiles</key> <array> <string>icon-128.png</string> </array> <key>UTTypeIdentifier</key> <string>com.digital-dirtbag.foobar</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>foobar</string> </array> </dict> </dict> The question is does DocumentGroup on iOS even support opening documents directly into the editor view? I know it works on macOS as expected as I tried this with the demo code and it exhibits the same symptoms. Opening a document from iOS Files.app only gets you as far as the document browser while macOS will open an editor directly.
Topic: UI Frameworks SubTopic: SwiftUI
0
0
78
May ’25
SwiftUI TextField does not update its displayed text when I transform input inside a custom Binding
I’m trying to transform user keyboard input in a TextField so that, for example, whenever the user types the letter "a" it is stored and shown as the Greek letter "α". I created a custom Binding to intercept and modify the typed text before saving it to my observable model. Here’s a simplified version of my code: import SwiftUI class User: ObservableObject { @Published var username: String = "" } struct ContentView: View { @ObservedObject var user = User() var usernameBinding: Binding<String> { Binding( get: { user.username }, set: { newValue in // Replace all "a" with "α" user.username = newValue.replacingOccurrences(of: "a", with: "α") } ) } var body: some View { TextField("Username", text: usernameBinding) .padding() .onChange(of: user.username) { newValue in print("username changed to:", newValue) } } } When I type "a", I can see in the console that the onChange handler prints the transformed string ("α"), and the model (user.username) is updated. However, the TextField on screen still shows the original "a" instead of updating to "α" immediately. I expected the text field to update its displayed value whenever the bound property changes (since username is @Published on an ObservableObject), but that doesn’t seem to happen when I modify the text in the binding’s set closure. Is this a known limitation of SwiftUI TextField? Is there a better way to transform user input so the field shows the transformed text based on some processing? Any advice or explanation would be appreciated.
0
0
90
Sep ’25
Enabling Show Tab Bar Programmatically
I have a macOS application developed in SwiftUI. It's a document-based application. I know how to hide the Show Tab Bar command under View. I don't want to hide it. I always want to show tabs. I wonder how to enable this command programmatically such that the document window always has the + button to the right. Thanks.
Replies
0
Boosts
0
Views
119
Activity
May ’25
NavigationPath.append but .navigationDestination Not Being Called
I am trying to do a bit of fancy navigation in SwiftUI using NavigationPath and am having a problem. I have a root view with includes a button: struct ClassListScreen: View { @Bindable private var router = AppRouter.shared @State private var addCourse: Bool = false ... var body: some View { ... Button("Add Class") { router.currentPath.append(addCourse) }.buttonStyle(.borderedProminent) ... .navigationDestination(for: Bool.self){ _ in ClassAddDialog { course in sortCourses() } } } } router.currentPath is the NavigationPath associated with the operative NavigationStack. (This app has a TabView and each Tab has its own NavigationStack and NavigationPath). Tapping the button correctly opens the ClassAddDialog. In ClassAddDialog is another button: struct ClassAddDialog: View { @Bindable private var router = AppRouter.shared @State private var idString: String = "" ... var body: some View { ... Button("Save") { let course = ... ... (save logic) idString = course.id.uuidString var path = router.currentPath path.removeLast() path.append(idString) router.currentPath = path }.buttonStyle(.borderedProminent) ... .navigationDestination(for: String.self) { str in if let id = UUID(uuidString: str), let course = Course.findByID(id, with: context) { ClassDetailScreen(course: course) } } } } My intent here is that tapping the Save button in ClassAddDialog would pop that view and move directly to the ClassDetailScreen (without returning to the root ClassListScreen). The problem is that the code inside the navigationDestination is NEVER hit. (I.e., a breakpoint on the if let ... statement) never fires. I just end up on a (nearly) blank view with a warning triangle icon in its center. (And yes, the back button takes me to the root, so the ClassAddDialog WAS removed as expected.) And I don't understand why. Can anyone share any insight here?
Replies
0
Boosts
1
Views
105
Activity
Oct ’25
Zoom navigation causes the source view to disappear
After returning from the child view to the parent, the latter one will simply disappear. This is the full view. See itemsContent where I perform the navigation. The last tapped rectangle in this example will simply disappear. struct DashboardView: View { @State var viewModel: DahsboardViewModel @Namespace private var namespace var body: some View { ScrollView(.vertical) { LazyVStack(spacing: 24) { ForEach(viewModel.sections) { section in VStack(spacing: 16) { Text(section.title) itemsContent(for: section) } } } } } func itemsContent(for section: DashboardSection) -> some View { ForEach(section.items) { item in NavigationLink { PatternLearningRouter().rootView .id(item.id) .navigationTransition(.zoom(sourceID: item.id, in: namespace)) } label: { Rectangle() .fill(Color.yellow) .frame(width: 80, height: 80) .overlay { Text(item.title) } .matchedTransitionSource(id: item.id, in: namespace) } } } } XCode26 26.0.1(17A400) iPhone 16 Pro, iOS 26.0.1 Note: Only reproduced when I swipe back (not reproducing it when using back button) Only reproduced on real device not simulator I
Replies
0
Boosts
1
Views
84
Activity
Oct ’25
When is the StateObject’s autoclosure actually called?
The signature of the StateObject initializer is init(wrappedValue thunk: @autoclosure @escaping () -> ObjectType). The fact that the autoclosure is marked as escaping intrigues me, because that suggests that it could be called after the init has returned. Why this is interesting is because I have some code where the viewmodel given to the @StateObject depends on an implicitly unwrapped optional type, and I expect the top level initialization of the StateObject to crash because the implicitly unwrapped optional is not ready yet, but to my surprise it did not. My theory is that the autoclosure is being called after the View’s initialization had been called, when the dependency is ready. heres a minimal sample of that. class MyDependency: ObservableObject { @Published var value = "Hello" } class MyViewModel: ObservableObject { let dependency: MyDependency init(dependency: MyDependency = TestApp.dependency) { self.dependency = dependency print("✅ ViewModel initialized with dependency:", dependency.value) } } struct ContentView: View { @StateObject private var viewModel = MyViewModel() // ⚠️ expected crash? var body: some View { Text(viewModel.dependency.value).onAppear { TestApp.dependency = Dependency()// dependency is set here after init has been called } } } @main struct TestApp: App { static var dependency: MyDependency! // not ready yet var body: some Scene { WindowGroup { ContentView() } }```
Replies
0
Boosts
0
Views
135
Activity
Oct ’25
Document-based app: file picker flickers since macOS 26 update
Description: Since updating to Tahoe, the file picker dialog briefly flickers immediately after opening in my document-based app. This behavior did not occur on macOS Sequoia. Rhe issue does not appear in TextEdit, but it does occur in Paper (a writing app) and Kaleidoscope. Based on this, it seems to affect third-party document-based apps that use standard open panels. Steps to Reproduce: 1. Launch a third-party document-based app. 2. Open the file picker (e.g., via “Open…”). 3. Observe a brief flicker as the dialog appears. Expected Result: The file picker dialog should open smoothly without flickering. Actual Result: The file picker dialog flickers briefly right after appearing. Notes: • Issue introduced in macOS Tahoe. • Not reproducible in macOS Sequoia. Reported through Feedback Assistant: FB20522119
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
0
Boosts
0
Views
150
Activity
Oct ’25
Unknown error when displaying IntentItems with images in widget configuration intent
Hi everyone, I’m building a simple sticky notes app that allows users to place a note widget on their home screen. Each widget displays a user-created sticky note. To let users choose which note to show, I’ve implemented an Intent that presents a list of existing sticky notes. The list is built using IntentItems, and for each item I assign an image to visually represent the note. Each sticky note can have a different background color and optional image, so I generate a small PNG (150×150, ~30 KB) and include it in the app bundle. However, when I try to display the selection list, I get the following error: The action Select sticky note could not run because an unknown error occurred. If I tap OK and try again, the intent selector appears and works. Here’s what I’d like to understand: What could cause this unknown error when using images in IntentItems? Are there known limitations on image size, source, or format for intent item images? Can I supply a unique image per sticky note, or must all intent items share a common image? Any guidance or insights would be greatly appreciated — I haven’t been able to find clear documentation about image handling in IntentItem for widget configuration. Thanks!
Replies
0
Boosts
0
Views
112
Activity
Oct ’25
SwiftUI PhotoPicker always warning in swift6.2
When I migrate to swift6.2, the photopicker always giving the warning like below: Call to main actor-isolated initializer 'xxxfunction' in a synchronous nonisolated context it's so weird,because no matter it's a viewbuilder or a struct view,it can't fix the warning.
Replies
0
Boosts
0
Views
107
Activity
Oct ’25
Bottom toolbar Button truncated on Mac Catalyst 26
On Mac Catalyst 26, a Button bar item in a bottom toolbar look squished. This happens only when the "Mac Catalyst Interface" option is set to "Optimize for Mac". When it is set to "Scale to match iPad", the buttons look fine. For example, in the screenshots below, the text button should say "Press Me", instead of "…" A simple reproducible snippet and a screenshot below. The toolbar button comparison between "Scale to match iPad" and "Optimize for Mac" are shown. Optimize for Mac Scale to match iPad import SwiftUI struct ContentView: View { @State private var selectedItem: String? = "Item 1" let items = ["Item 1", "Item 2"] var body: some View { NavigationSplitView { List(items, id: \.self, selection: $selectedItem) { item in Text(item) } .navigationTitle("Items") } detail: { if let selectedItem = selectedItem { Text("Detail view for \(selectedItem)") .toolbar { ToolbarItemGroup(placement: .bottomBar) { Text("Hello world") Spacer() Button("Press Me") { } Spacer() Button { } label: { Image(systemName: "plus") .imageScale(.large) } } } } else { Text("Select an item") } } } }
Replies
0
Boosts
1
Views
281
Activity
Oct ’25
ToolbarItems under tabView BottomBar on iOS26
The iOS with TabView places the .bottomBar toolbar items under the TabView items and does not raise them on top of them. iPadOS (when resized to a smaller width where the TabView places to the bottomBar) and previous iOS18 on iOS and iPadOS works correctly. Reported (FB20447249)
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
1
Views
74
Activity
Sep ’25
How to detect modifier keys with hardware keyboard in SwiftUI (iOS)?
Hi everyone, In UIKit, I can detect which key and modifier keys are pressed from an external hardware keyboard using the pressesBegan method in a UIResponder: override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) { for press in presses { if let key = press.key { print("Key: \(key.charactersIgnoringModifiers ?? "")") print("Modifiers: \(key.modifierFlags)") } } } I am now working in SwiftUI (iOS), and I couldn’t find a direct equivalent for pressesBegan. What is the recommended way in SwiftUI to detect modifier keys + key presses from an external keyboard? Is there a built-in API, or should I always wrap a UIKit view/controller for this purpose? Thanks in advance!
Replies
0
Boosts
0
Views
72
Activity
Sep ’25
SwiftUI: Can a NavigationDestination in NavigationStack present the view as a .sheet instead of pushing?
Hi everyone, I’m experimenting with SwiftUI's new NavigationStack / navigationDestination API. Normally, when you navigate to a value using NavigationLink(value:) and a matching navigationDestination(for:), the destination view is pushed onto the navigation stack. What I’d like to know is: Is there a way to present that destination view as a sheet instead of pushing it? Essentially: Can a NavigationDestination be shown modally? Here’s a simplified example of what I mean: struct RootView: View { var body: some View { NavigationStack { NavigationLink(value: "Example") { Text("Push me!") } .navigationDestination(for: String.self) { _ in DetailView() // <--- Can this be shown as a sheet? } } } } My questions are: Is there a built‑in way to make a navigationDestination present modally (as .sheet) instead of pushing? If not, is the recommended approach to handle .sheet state manually outside of the NavigationStack and bypass navigationDestination for such cases? Can the NavigationPath itself somehow encode a modal presentation style for certain types? Thanks in advance for any tips or confirmation that this is (not) possible in SwiftUI.
Replies
0
Boosts
0
Views
109
Activity
Sep ’25
How to apply SwiftUI window modifiers when using Xcode's #Preview on a macOS view?
Is there a way to configure the style and toolbar of the macOS window that Xcode uses in #Preview? I am working on a macOS application and want to preview some SwiftUI views within different window styles, toolbar styles and window title/subtitle visibilities. Some of the modifiers to control the look-and-feel of a window are actually Scene Modifiers, not View Modifiers: .windowStyle .windowToolbarLabelStyle .windowToolbarStyle But #Preview does not accept Scenes, so I can't apply these modifiers: // Error, not a view modifier. #Preview { ContentView() .windowStyle(...) } // Error, Window is not supported in #Preview. #Preview { Window("Browser", id: "browser") { ContentView() } } If I give my ContentView a .toolbar(...), Xcode's Preview will correctly show a window with a toolbar, but not necessarily in the style I want. Is there a way to apply the Scene Modifiers to #Preview so that I can see how they affect the window's chrome and toolbar?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
0
Boosts
1
Views
84
Activity
Oct ’25
SwiftUI Glyphs clipped, how do I show the entire glyph?
This code: import SwiftUI struct heightProblem: View { var body: some View { Text("\u{1D15E} \u{1D15F} \u{1D160} \u{1D161} \u{1D162} \u{1D163} \u{1D164}") .font(Font.largeTitle.bold()) .frame(height: 50.0) .border(.red) .padding() .border(.green) } } #Preview { heightProblem() } Produces this display: Note the clipping. Lowering the baseline by about 20 brings it into view, but this is a horrible fix for dynamic display (The font is Noto, which works just fine in Xcode, but not in Safari for some reason.)
Replies
0
Boosts
0
Views
122
Activity
Sep ’25
SwiftUI TextField with lineLimit inside Form does not respect lineLimit.
macos 26, xcode 26, ios 26. Everytime when you add new line at some point (like after 10-20 lines) the TextField will ignore the lineLimit and start changing the height. The problem related to Form but not Scroll. Maybe it can be reproduced in other scroll-based views. Bug report opened. Any siggestions? struct Test: View { @State var text = "" var body: some View { Form { Section { TextField("", text: $text, axis: .vertical) .lineLimit(3) .background(Color.green) } } } } @main struct TestApp: App { var body: some Scene { WindowGroup { Test() } } }
Replies
0
Boosts
0
Views
76
Activity
Sep ’25
timeline method is not being called for AppIntentTimelineProvider implementation on iOS 17 only
I have a widget that runs well on iOS 18. It is configurable and implements AppIntentTimelineProvider on the Provider. On iOS 17 it will call the placeholder method 7 times and not call the timeline method. The configuration intent implements WidgetConfigurationIntent. I've looked through the console logs and saw "ApplicationExtension record not found" but I'm not sure where to go from there. Why would the same widget work fine on iOS 18 and not 17? If I implement TimelineProvider and use a StaticConfiguration it works on iOS 17. Any help / guidance would be appreciated.
Replies
0
Boosts
0
Views
120
Activity
Jun ’25
I used colorpick on the view, but after converting it to a entity, colorpick doesn't work. Is there any way to use colorpick
I used colorpick on the view, but after converting it to a model, colorpick doesn't work. Is there any way to use colorpick
Replies
0
Boosts
0
Views
80
Activity
Oct ’25
Showing space .navigationTitle leads to unexpected results.
I wanted to set navigationTitle value to space symbol on my iOS app (Swift 6, iOS 26.0) (so that navigationBar opens in large mode initially before the actual value is being fetched). In my view I used this: .navigationTitle(" ") And on device I got unexpectedly two quote symbols: Not sure if there is space in between, and the symbols look like opening and closing quote (both quotes in code I think are the same symbols) - so probably it's not part of my code is visible in UI as one might think... . Is this a bug? Or undocumented feature?
Replies
0
Boosts
1
Views
124
Activity
Sep ’25
tvOS 26 Top shelf's playbackProgress is broken
Here is a minimal code private func createItem(from movie: Movie, showProgress: Bool, imageType: ImageType) -> TVTopShelfSectionedItem { let item = TVTopShelfSectionedItem(identifier: movie.id) // Set title for the item item.title = movie.title switch imageType { case .landscape: item.imageShape = .hdtv // HDTV shape for landscape/backdrop images if let backdropUrl = movie.backdropUrl, let url = URL(string: backdropUrl) { item.setImageURL(url, for: .screenScale2x) } case .poster: item.imageShape = .poster // Poster shape for poster images if let posterUrl = movie.posterUrl, let url = URL(string: posterUrl) { item.setImageURL(url, for: .screenScale2x) } } if showProgress { item.playbackProgress = 0.5 } return item } As you can see the progress bar is pushed to the bottom. There is no padding around it. Am I doing something wrong or this is bug in the framework?
Replies
0
Boosts
0
Views
220
Activity
Sep ’25
Open file directly into editor view with DocumentGroup
This was also raised in FB17028569 I have iOS document based app using DocumentGroup. I can create and save documents as expected. All that functionality is fine. @main struct FooBarApp: App { var body: some Scene { DocumentGroup(newDocument: { FoobarDocument() }) { config in MainView(document: config.document) } The problem is when I open an app document from Files.app or Messages the document is never opened directly into the editor, the document browser interface is always presented and the user must manually select the document to open an editor. This also happens when I use UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil) to open a new scene. The doc isn't opened into my editor. I believe my plist document types are setup correctly and that my ReferenceFileDocument is setup correctly <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeExtensions</key> <array> <string>foobar</string> </array> <key>CFBundleTypeIconFile</key> <string>icon-128</string> <key>CFBundleTypeIconSystemGenerated</key> <integer>1</integer> <key>CFBundleTypeMIMETypes</key> <array> <string>application/json</string> </array> <key>CFBundleTypeName</key> <string>Foobar Project</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.digital-dirtbag.foobar</string> </array> <key>NSUbiquitousDocumentUserActivityType</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER).ubiquitousdoc</string> </dict> </array> <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>Foobar Project</string> <key>UTTypeIconFiles</key> <array> <string>icon-128.png</string> </array> <key>UTTypeIdentifier</key> <string>com.digital-dirtbag.foobar</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>foobar</string> </array> </dict> </dict> The question is does DocumentGroup on iOS even support opening documents directly into the editor view? I know it works on macOS as expected as I tried this with the demo code and it exhibits the same symptoms. Opening a document from iOS Files.app only gets you as far as the document browser while macOS will open an editor directly.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
78
Activity
May ’25
SwiftUI TextField does not update its displayed text when I transform input inside a custom Binding
I’m trying to transform user keyboard input in a TextField so that, for example, whenever the user types the letter "a" it is stored and shown as the Greek letter "α". I created a custom Binding to intercept and modify the typed text before saving it to my observable model. Here’s a simplified version of my code: import SwiftUI class User: ObservableObject { @Published var username: String = "" } struct ContentView: View { @ObservedObject var user = User() var usernameBinding: Binding<String> { Binding( get: { user.username }, set: { newValue in // Replace all "a" with "α" user.username = newValue.replacingOccurrences(of: "a", with: "α") } ) } var body: some View { TextField("Username", text: usernameBinding) .padding() .onChange(of: user.username) { newValue in print("username changed to:", newValue) } } } When I type "a", I can see in the console that the onChange handler prints the transformed string ("α"), and the model (user.username) is updated. However, the TextField on screen still shows the original "a" instead of updating to "α" immediately. I expected the text field to update its displayed value whenever the bound property changes (since username is @Published on an ObservableObject), but that doesn’t seem to happen when I modify the text in the binding’s set closure. Is this a known limitation of SwiftUI TextField? Is there a better way to transform user input so the field shows the transformed text based on some processing? Any advice or explanation would be appreciated.
Replies
0
Boosts
0
Views
90
Activity
Sep ’25