Search results for

swiftui

16,633 results found

Post

Replies

Boosts

Views

Activity

Reply to Need help with attribute inspector in Xcode 26
but the attribute inspector just does not show up, I can have the simulator open or closed I click on it nothing works. Can you provide more details about what you are trying to do that doesn't work? What do you mean by attribute inspector? You mentioned you are learning SwiftUI. The attributes inspector is used with storyboards, which SwiftUI does not use. SwiftUI uses previews to let you see how your user interface looks before you run your app. Are you trying to open the attributes inspector? Or are you trying to show the SwiftUI preview? Or are you trying to do something else?
Topic: UI Frameworks SubTopic: SwiftUI
Sep ’25
Document title/proxy shifts left when adding an empty SwiftUI/AppKit toolbar - how to keep it centered?
I’m building a document-based macOS app using SwiftUI with an AppKit NSDocument. By default, when the window has no toolbar, the document title and proxy icon (with the edited state dot and standard saving controls) appear nicely centered in the title bar. However, as soon as I attach a toolbar - even an empty one - the document proxy moves to the leading edge of the title bar. Is there a way to keep the document proxy/title centered in a document-based SwiftUI app while also using a toolbar? Or is the left-alignment now the only supported behavior when a toolbar is present? Thanks in advance for any guidance.
2
0
116
Sep ’25
ScrollView breaks with LazyVGrid and Searchable on iOS 26 (only on older devices)
When using LazyVGrid within a ScrollView with the .searchable modifier, scrolling is impossible on iPhone 15 (I’m assuming other older devices are affected too). This behavior does not occur on iPhone 16 and newer. This also only happens, when the search bar is placed at the top, for example if the ScrollView is within a TabView. Here's a short screen recording of the issue: And this is a minimal example causing the issue: import SwiftUI struct ContentView: View { var body: some View { TabView { Tab(Text, systemImage: gear) { ExampleTab() } } } } struct ExampleTab: View { @State private var searchText: String = var body: some View { NavigationStack { ScrollView { LazyVGrid( columns: [GridItem( .adaptive(minimum: 120) )], spacing: 20 ) { ForEach(1..<100) { index in Text(Test (index)) } } } .searchable(text: self.$searchText) } } }
1
0
81
Sep ’25
Popover in Toolbar Causes Crash in Catalyst App on macOS 26
Hi everyone, I’ve encountered an issue where using a popover inside the toolbar of a Catalyst app causes a crash on macOS 26 beta 5 with Xcode 26 beta 5. Here’s a simplified code snippet: import SwiftUI struct ContentView: View { @State private var isPresentingPopover = false var body: some View { NavigationStack { VStack { } .padding() .toolbar { ToolbarItem { Button(action: { isPresentingPopover.toggle() }) { Image(systemName: bubble) } .popover(isPresented: $isPresentingPopover) { Text(Hello) .font(.largeTitle) .padding() } } } } } } Steps to reproduce: Create a new iOS app using Xcode 26 beta 5. Enable Mac Catalyst (Match iPad). Add the above code to show a Popover from a toolbar button. Run the app on macOS 26, then click the toolbar button. The app crashes immediately upon clicking the toolbar button. Has anyone else run into this? Any workarounds or suggestions would be appreciated! Thanks!
3
0
167
Sep ’25
SwiftUI Table Header Background not appearing in iPadOS 26
Hi, it seems like using Table on iPadOS 26 results in the table header not applying a background. When comparing the same code on iPadOS 18, the table header applies a blur behind the header to ensure legibility when the user scrolls the content. Is there a way to ensure Table applies a background effect to the header so that content remains legible during scrolling? Here is a minimal example: struct TablePreviewContent: Identifiable { var id: Int { text.hashValue } var text: String } #Preview { let content = [TablePreviewContent(text: Hello), TablePreviewContent(text: World)] Table(content) { TableColumn(Title, value: .text) } } I've attached screenshots of the behavior on iPadOS 26 compared to iPadOS 18 to illustrate the issue.
3
0
146
Sep ’25
Mutating an array of model objects that is a child of a model object
Hi all, In my SwiftUI / SwiftData / Cloudkit app which is a series of lists, I have a model object called Project which contains an array of model objects called subprojects: final class Project1 { var name: String = @Relationship(deleteRule: .cascade, inverse: Subproject.project) var subprojects : [Subproject]? init(name: String) { self.name = name self.subprojects = [] } } The user will select a project from a list, which will generate a list of subprojects in another list, and if they select a subproject, it will generate a list categories and if the user selects a category it will generate another list of child objects owned by category and on and on. This is the pattern in my app, I'm constantly passing arrays of model objects that are the children of other model objects throughout the program, and I need the user to be able to add and remove things from them. My initial approach was to pass these arrays as bindings so that I'd be able to mutate them. This worked for the most part but there wer
5
0
225
Sep ’25
Draw SwiftUI.Form style pop-up button with NSPopUpButton in AppKit
In SwiftUI on macOS, A menu-style Picker is drawn as a pop-up button. It generally looks and behaves the same as an NSPopUpButton in AppKit. SwiftUI introduced iOS-like looking UI for settings in macOS, and consequently, the Picker also has its own style when placed inside a Form. A Form-style Picker displays only up/down chevrons and draws the background only when the mouse hovers over it. It also changes its width dynamically based on the selected item. Form { Picker(Animal:, selection: $selection) { ForEach([Dog, Cow], id: .self) { Text($0) } .pickerStyle(.menu) } You can find it, for instance, in the Print dialog. My question is: I couldn't find a way to draw an NSPopUpButton in AppKit with this style. Does anyone know how to achieve this in AppKit? Some might say I should just use SwiftUI straightforwardly, but I would like to use it in a print panel accessory that currently still avoids using SwiftUI but its dialog has SwiftUI.Form-looking.
4
0
157
Sep ’25
Preventing animation glitch when dismissing a Menu with glassEffect
Hi everyone, I’m running into a strange animation glitch when using a Menu inside a glassEffect container. Here’s a minimal example: import SwiftUI struct ContentView: View { @Namespace private var namespace var body: some View { ZStack { Image(.background) .resizable() .frame(maxWidth: .infinity, maxHeight: .infinity) .ignoresSafeArea() GlassEffectContainer { HStack { Button(b1) {} Button(b2) {} Button(b3) {} Button(b4) {} Button(b5) {} Menu { Button(t1) { } Button(t2) { } Button(t3) { } Button(t4) { } Button(t5) { } } label: { Text(Menu) } } } .padding(.horizontal) .frame(height: 50) .glassEffect() } } } What happens: The bar looks fine initially: When you open the Menu, the entire bar morphs into the menu: When dismissing, the bar briefly animates into a solid rectangle before reapplying the glass effect: Questions: Is there a way to prevent that brief rectangle animation when dismissing the menu? If not, is it possible to avoid the morphing altogether and have the menu simply overlay on top of th
1
0
359
Sep ’25
Reply to `onTapGesture` not triggered on `Map` views
For those having to deal with that bug and in need to get location for the tap, I've used the answer here https://stackoverflow.com/questions/56513942/how-to-detect-a-tap-gesture-location-in-swiftui with a slight modification : import SwiftUI struct ClickGesture: Gesture { let count: Int let coordinateSpace: CoordinateSpace typealias Value = SimultaneousGesture.Value init(count: Int = 1, coordinateSpace: CoordinateSpace = .local) { precondition(count > 0, Count must be greater than or equal to 1.) self.count = count self.coordinateSpace = coordinateSpace } var body: SimultaneousGesture { SimultaneousGesture( TapGesture(count: count), DragGesture(minimumDistance: 0, coordinateSpace: coordinateSpace) ) } func onEnded(perform action: @escaping (CGPoint) -> Void) -> _EndedGesture { self.onEnded { (value: Value) -> Void in guard value.first != nil else { return } guard let location = value.second?.startLocation else { return } guard let endLocation = value.second?.location else { retu
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to I need help
You don't show the code, so hard to say. A good series of books can be found on Apple's pathways: https://developer.apple.com/pathways/ There is full section for SwiftUI and much more.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
iOS 26 Beta breaks scroll/gesture in SwiftUI chat (worked in iOS 18): Simultaneous gestures & ScrollViewReader issues
Hi all, After upgrading to the iOS 26 beta, the scrolling in my SwiftUI chat view is completely broken. The exact same code works perfectly on iOS 18. Context: I have a chat view using ScrollViewReader and a vertically-reversed ScrollView (with .rotationEffect(.degrees(180))). Each message row (MessageBubble) uses multiple simultaneousGesture handlers: Horizontal drag for swipe-to-reply (and other actions: pin, delete) Long press for showing popover/actions Vertical scroll for normal chat scrolling This was working great on iOS 18. In iOS 26 beta, the vertical scroll is either completely disabled, jittery, or hijacked by the message row’s drag gestures, even though .simultaneousGesture is used (see code below). Minimal Repro Sample MessageListView.swift swift Copy Edit ScrollViewReader { proxy in ScrollView(.vertical, showsIndicators: false) { LazyVStack(spacing: 0) { // ... grouped messages ForEach(...) { ... MessageBubble(...) // see below } Color.clear.frame(height: 8).id(BOTTOM_ANCHOR) } .padding
8
0
869
Sep ’25
Reply to Menu presentation in UIHostingController issues
Found this thread when researching an issue with the same log message in a pure SwiftUI app. There's a nasty layout/animation associated with what I'm seeing (but I'm not sure it's related to the log). A sample project to repro is attached to FB20272800 (apologies for hijacking OP's thread, but I thought it might perhaps be interesting to them that issue reproduces in iOS 26 without using a UIHostingController in our own code. A simple Menu suffices)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’25
Reply to Novice SwiftUI developer can't make network call
Indeed, I have reviewed your response. Print statements are indeed supported in SwiftUI and are displayed on the Xcode console. However, I am still unclear about your request for a “free API key for stock info.” Could you please provide additional details? Are the sample request I have provided effective for you? Albert Pascual
  Worldwide Developer Relations.
Topic: Design SubTopic: General
Sep ’25