Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

Posts under SwiftUI tag

200 Posts

Post

Replies

Boosts

Views

Activity

Did VisionOS27 get the LazyVGrid Performance Updates?
Did VisionOS get the LazyVGrid Performance Updates that other platforms received? I’m observing that a LazyVGrid that works well on iPhone, iPad, and Mac appears to hitch and jitter as cells exit and renter the lazyVGrid on VisionOS. It really feels like it did not get the same behavior changes as the other platforms. I observe the scrollbar expands as cells leave the top of the grid, and each “exit” of a row seems to cause a hitch. I’ve got rigidly defined cell frames, rigidly defined columns. I don’t think any cells frames are being invalidated during scroll… (there’s no way to check this with instruments, right?) I‘ve made several analysis passes myself and threw the Xcode Agent with Codex at it just to scan for stuff, but it’s starting to just guess at things. Any known issues with VisionOS?
3
0
59
2h
Changing a State var in a Timer block doesn't update the UI
Can anyone explain to me why my UI doesn't update after the timer fires in this code below? Even when the timer fires, the UI doesn't update. thanks, in advance for any guidance Mike struct ContentView: View { @State var referenceDate: Date = Date() init () { setupTimer() } func setupTimer() { let calendar = Calendar.current guard let triggerDate = calendar.nextDate( after: Date(), matching: DateComponents(hour: 14, minute: 46, second: 0), matchingPolicy: .nextTime ) else { return } let timer = Timer(fire: triggerDate, interval: 0.2, repeats: false) { _ in self.referenceDate = Date() print("runLoop!") } RunLoop.main.add(timer, forMode: .common) } var body: some View { VStack { Text("Ref time: \(referenceDate.formatted(date: .abbreviated, time: .standard))") } } }
2
0
52
1d
How to get the correct animation when inserting/removing a row in a SwiftUI List from a swipeAction?
Hello, In my app, I have a List with two sections. The first section contains favourited items. The second section contains all the items. I use a swipeAction to favorite / undo favorite an item. An item can be in the first section and in the second section. But when I use the swipeAction to perform the action, the row animation is conflicting with the List animation for insertion / removal (I think). It’s not synchronised and it leads to an ugly UX. GeometryGroup on the Section does not help. One solution is to delay the action so the swipe has enough time to go back to its original position but it’s hacky and depends too much on manual timing, etc. If I favorite / undo from a tap on the row (no swipe action), the animation is correct (obviously, as the row doesn’t need to animate to its original position). I experimented with a ScrollView + swipeActionsContainer() + swipeActions on iOS 27, and it works very nicely. But this solution only works for iOS 27 and my app targets iOS 18. So I would love to have a native implementation for iOS 18+ if possible. Am I missing something to get the correct animation with a List? You can check the attached code: https://gist.github.com/alpennec/f9de25cda29b515eb45af6b368a89ed8 Video: https://www.dropbox.com/scl/fi/sqitivihm4pbu8htxicap/ListSectionsSwipeActions.mov?rlkey=08wl708g82rmyy6nkf75725bv&st=0qb7rhdd&dl=0 I also filed a feedback with a video: FB23661327 Regards, Axel
1
1
46
1d
Drag and Drop stopped working after upgrading from macOS 15 to 26
When I drag and drop a file with flag "shouldAttemptToOpenInPlace: true", I was able to access the original file name in macOS 15. After upgrading to macOS 26, I can't access the original file name anymore. Instead, I got some useless file name such as ".com.apple.Foundation.NSItemProvider.gKZ91u.tmp". The app no longer works with these tmp filenames because it needs the orignal file name to do the file transfer. (Btw, this is a WinSCP like app on Mac platform) Could you please check and fix this issue? Thank you. FileRepresentation(contentType: .item, shouldAttemptToOpenInPlace: true)
2
0
477
1d
How can a SwiftUI drag provide the actual file URL of an existing file on macOS (as NSOutlineView does)?
I'm dragging existing files from a SwiftUI List (a search result list in a sandboxed, document-based Mac app), and I want drop targets to receive the actual file URL — the same behavior as AppKit's NSOutlineView with outlineView(_:pasteboardWriterForItem:) returning an NSURL: the Finder copies the file, browsers load it, and text views insert its path. My current implementation is Transferable-based: FileRepresentation(exportedContentType: .data) { item in SentTransferredFile(item.fileURL, allowAccessingOriginalFile: true) } .suggestedFileName(\.fileURL.lastPathComponent) With this, what receivers get is a temporary copy in the app's own container (Caches/com.apple.SwiftUI.Drag-<UUID>/), not the actual file URL — despite allowAccessingOriginalFile: true. Dropping on the Finder or onto an application icon works through the copy, but receivers that interpret the URL itself — a browser window, or a text view that inserts the dropped file's path — see the temporary container path. Note that the dragged files live inside a folder the user has opened as a document (the app is NSDocument-based), so the app already holds security-scoped access to them. Alternatives don't help either: DataRepresentation(exportedContentType: .fileURL) returning the URL bytes of the actual file: the pasteboard data is likewise replaced with the copy's URL, and moreover, drops onto application icons (e.g. Safari in the Dock) are no longer accepted at all. onDrag with NSItemProvider(object: url as NSURL): same substitution. I've already filed this as FB23578716, with detailed reproduction steps and drag-pasteboard dumps. My questions: Is there any way in current SwiftUI (macOS 26/27 SDK) to put the real file URL of an existing file on the drag pasteboard? Is the rewriting to a temporary copy intended behavior (for sandbox safety), or a bug? If it's intended, is embedding an AppKit view that calls beginDraggingSession(with:event:source:) with an NSURL pasteboard writer the recommended workaround for now? It does write the real URL, but making it coexist with List's selection and click handling has proven fragile. Environment: macOS: macOS 27 Beta 2 / Version 26.5.2 Xcode: Version 27.0 Beta 2 App Sandbox enabled
3
0
113
2d
SwiftUI ​Charts: In iOS 27, annotation overlays exceed the bounds of an annotation
I'm seeing a regression in SwiftUI Charts on iOS 27 beta 1. Any view placed inside a BarMark's overlay annotation no longer receives the size of the parent BarMark. It collapses to zero, so any content sized from geo.size (e.g. a Rectangle meant to fill the bar) renders empty or incorrectly. Expected: The GeometryReader reports the BarMark's rendered width/height, and the Rectangle fills the BarMark (this is the behavior in iOS 26 and earlier). Actual: On iOS 27 beta 1, geo.size is effectively zero, so the overlay content has an extremely small size. I suspect this could be a small bug with the new ContentBuilder / ViewBuilder changes but that's just a hunch. Here's a code sample which reproduces the issue. // MARK: - Mock Data Models struct ScheduleSeries: Identifiable { let id = UUID() let data: [ScheduleItem] } struct ScheduleItem: Identifiable { let id = UUID() let startDate: Date let startHour: Double let endHour: Double let secondaryText: String? } // MARK: - Minimal Reproducible Example struct ContentView: View { // Generate two consecutive days for the mock data let mockSchedule: [ScheduleSeries] = [ ScheduleSeries(data: [ ScheduleItem( startDate: Date(), startHour: 9.0, endHour: 11.5, secondaryText: "Morning Event" ), ScheduleItem( startDate: Calendar.current.date(byAdding: .day, value: 1, to: Date())!, startHour: 13.0, endHour: 16.0, secondaryText: "Afternoon Event" ) ]) ] var body: some View { VStack(alignment: .leading) { Text("FB: Annotation Sizing Bug") .font(.headline) .padding(.bottom, 8) Text("Expected: The gray Rectangle should stretch to fill the BarMark.\nActual: GeometryReader/Annotation fails to size to the parent BarMark.") .font(.caption) .foregroundColor(.secondary) .padding(.bottom) Chart(mockSchedule) { series in ForEach(series.data, id: \.startDate) { element in BarMark( x: .value("Day", element.startDate, unit: .day, calendar: .current), yStart: .value("Start", element.startHour), yEnd: .value("End", element.endHour), width: .ratio(0.99) ) .annotation(position: .overlay, alignment: .topLeading) { item in ZStack { VStack(alignment: .leading, spacing: 0) { // BUG DEMONSTRATION: // This GeometryReader and Rectangle previously filled the BarMark, but in Xcode 27 it does not GeometryReader { geo in Rectangle() .fill(Color.black.opacity(0.15)) .frame(width: geo.size.width, height: geo.size.height) } } .foregroundColor(.white) .font(.caption2) } } } } .chartYScale(domain: 0...24) // Lock the Y-axis to a 24-hour scale } .padding() } } Environment: Xcode 27 beta 1 / iOS 27 beta 1 Reproduces on device and Simulator Worked as expected on iOS 26 and earlier Here's what the issue looks like in our app with zero code changes: iOS 26 iOS 27 I've filed a feedback report (FB23016343) with a sample project attached. Has anyone else hit this, or found a workaround for sizing overlay annotation content to a BarMark in iOS 27? Thanks!
2
0
161
2d
Using `containerRelativeFrame` in a `List` on macOS leads to crash
The following code crashes as soon as the app launches. struct ContentView: View { var body: some View { List { Rectangle() .fill(.red) .containerRelativeFrame([.horizontal, .vertical]) } .frame(width: 400, height: 800) } } I would expect the code not to crash. Note that using a ScrollView works perfectly fine: struct ContentView: View { var body: some View { ScrollView { Rectangle() .fill(.red) .containerRelativeFrame([.horizontal, .vertical]) } .frame(width: 400, height: 800) } } The documentation clearly stipulates that it should work with a list: A scrollable view like ScrollView or List Using Xcode 26.5 (17F42) and simply created a new macOS project using SwiftUI. Feedback FB23655564
1
0
48
2d
SwiftUI confirmationDialog in List inside .sheet is no longer anchored to the originating row on iOS 27 beta
Area SwiftUI → Presentation / ConfirmationDialog Summary After building with Xcode 27 beta, confirmationDialog presented from a row inside a List that is embedded in a .sheet is no longer anchored to the row that triggered it. Instead, the dialog is displayed near the top of the sheet when the sheet is partially expanded, or in the center of the screen when the sheet occupies the full height. This behavior is reproducible across all tested Xcode 27 beta releases and iOS 27 beta releases (Beta 1, Beta 2, and Beta 3). Steps to Reproduce Present a SwiftUI .sheet. Place a List inside the sheet. Add a confirmationDialog to each list row. Trigger the dialog from a swipe action on any row. Observe the position where the confirmation dialog appears. A minimal reproducible sample project is attached. Expected Result The confirmationDialog should be visually associated with the row that triggered it, as it behaved in previous Xcode and iOS releases. The dialog should appear anchored to the selected list row (or as close as the platform allows), providing clear contextual feedback to the user about which item is being acted upon. Actual Result The dialog is no longer associated with the selected row. When the sheet is not fully expanded, the dialog appears near the top area of the sheet, seemingly positioned relative to the sheet itself rather than the triggering row. When the sheet is expanded to full height, the dialog appears in the center of the screen. As a result, the relationship between the selected item and the confirmation dialog is lost, creating a confusing user experience. Regression Yes. The same implementation behaved correctly in previous Xcode and iOS versions. The issue first appeared after upgrading to Xcode 27 beta and remains present in all tested iOS 27 beta releases (Beta 1–3). Impact This is a significant UX regression for existing applications that rely on contextual confirmation dialogs within lists presented inside sheets. Applications that already have production users cannot easily redesign their interaction model to compensate for this behavior change. The previous behavior provided clear context about which list item was being acted upon, while the current behavior makes that association unclear. Configuration Xcode 27 Beta (all tested beta versions) iOS 27 Beta 1 iOS 27 Beta 2 iOS 27 Beta 3 Reproduced on physical devices Reproduced using the attached minimal sample project Attachments Minimal reproducible sample project. Screenshot showing expected behavior (prior implementation). Screenshot showing current behavior on iOS 27 Beta 3. Screen recording demonstrating the regression. struct ContentView: View { @State private var sheetIsPresented = false @State private var itemPendingDeletion: Int? = nil var array = Array(0...100) var body: some View { VStack { Text("Hello, world!") Button("Show List") { sheetIsPresented = true } } .sheet(isPresented: $sheetIsPresented) { List { ForEach(array, id: \.self) { value in ListRow(for: value) .confirmationDialog("Delete?", isPresented: Binding( get: { itemPendingDeletion == value }, set: { isPresented in if !isPresented { itemPendingDeletion = nil } } ) ) { Button { } label: { Text("Delete") } } .swipeActions(edge: .trailing) { Button { itemPendingDeletion = value } label: { Image(systemName: "trash") .foregroundStyle(.red) } } } .listRowInsets(EdgeInsets()) .listRowBackground(Color.clear) } .listStyle(.inset) .contentMargins(16, for: .scrollContent) .presentationDetents([.fraction(1), .fraction(0.9)]) } } @ViewBuilder private func ListRow(for value: Int) -> some View { Text("\(value)") .foregroundStyle(.primary) .padding(.vertical) .frame(maxWidth: .infinity) .background( RoundedRectangle(cornerRadius: 26, style: .continuous) ) .padding(.vertical, 2) } } #Preview { ContentView() } Xcode 27(Beta 1,2,3) Xcode 26.5
0
0
49
3d
SwiftUI confirmationDialog in List inside .sheet is no longer anchored to the originating row on iOS 27 beta
Area SwiftUI → Presentation / ConfirmationDialog Summary After building with Xcode 27 beta, confirmationDialog presented from a row inside a List that is embedded in a .sheet is no longer anchored to the row that triggered it. Instead, the dialog is displayed near the top of the sheet when the sheet is partially expanded, or in the center of the screen when the sheet occupies the full height. This behavior is reproducible across all tested Xcode 27 beta releases and iOS 27 beta releases (Beta 1, Beta 2, and Beta 3). Steps to Reproduce Present a SwiftUI .sheet. Place a List inside the sheet. Add a confirmationDialog to each list row. Trigger the dialog from a swipe action on any row. Observe the position where the confirmation dialog appears. A minimal reproducible sample project is attached. Expected Result The confirmationDialog should be visually associated with the row that triggered it, as it behaved in previous Xcode and iOS releases. The dialog should appear anchored to the selected list row (or as close as the platform allows), providing clear contextual feedback to the user about which item is being acted upon. Actual Result The dialog is no longer associated with the selected row. When the sheet is not fully expanded, the dialog appears near the top area of the sheet, seemingly positioned relative to the sheet itself rather than the triggering row. When the sheet is expanded to full height, the dialog appears in the center of the screen. As a result, the relationship between the selected item and the confirmation dialog is lost, creating a confusing user experience. Regression Yes. The same implementation behaved correctly in previous Xcode and iOS versions. The issue first appeared after upgrading to Xcode 27 beta and remains present in all tested iOS 27 beta releases (Beta 1–3). Impact This is a significant UX regression for existing applications that rely on contextual confirmation dialogs within lists presented inside sheets. Applications that already have production users cannot easily redesign their interaction model to compensate for this behavior change. The previous behavior provided clear context about which list item was being acted upon, while the current behavior makes that association unclear. Configuration Xcode 27 Beta (all tested beta versions) iOS 27 Beta 1 iOS 27 Beta 2 iOS 27 Beta 3 Reproduced on physical devices Reproduced using the attached minimal sample project Attachments Minimal reproducible sample project. Screenshot showing expected behavior (prior implementation). Screenshot showing current behavior on iOS 27 Beta 3. Screen recording demonstrating the regression. struct ContentView: View { @State private var sheetIsPresented = false @State private var itemPendingDeletion: Int? = nil var array = Array(0...100) var body: some View { VStack { Text("Hello, world!") Button("Show List") { sheetIsPresented = true } } .sheet(isPresented: $sheetIsPresented) { List { ForEach(array, id: \.self) { value in ListRow(for: value) .confirmationDialog("Delete?", isPresented: Binding( get: { itemPendingDeletion == value }, set: { isPresented in if !isPresented { itemPendingDeletion = nil } } ) ) { Button { } label: { Text("Delete") } } .swipeActions(edge: .trailing) { Button { itemPendingDeletion = value } label: { Image(systemName: "trash") .foregroundStyle(.red) } } } .listRowInsets(EdgeInsets()) .listRowBackground(Color.clear) } .listStyle(.inset) .contentMargins(16, for: .scrollContent) .presentationDetents([.fraction(1), .fraction(0.9)]) } } @ViewBuilder private func ListRow(for value: Int) -> some View { Text("\(value)") .foregroundStyle(.primary) .padding(.vertical) .frame(maxWidth: .infinity) .background( RoundedRectangle(cornerRadius: 26, style: .continuous) ) .padding(.vertical, 2) } } #Preview { ContentView() } Xcode 27(Beta 1,2,3) Xcode 26.5
0
0
32
3d
Adaptive Layouts iOS 27
I was experimenting with existing APIs using a NavigationSplitView and noticed that in the SwiftUI preview, resizing causes the component to switch between the content view and the sidebar. However, with the new DeviceHub tool, the app doesn’t detect the new size and stays in the content view. Is this expected? I would expect Navigation Split View to handle size changes automatically. Is this expected behaviour? FB23340323
3
0
164
3d
iOS 27 beta 1: .scrollEdgeEffectStyle(.soft) renders fully transparent above safeAreaBar
Feedback ID: FB23086400 On iOS 27 beta 1, .scrollEdgeEffectStyle(.soft, for: .top) on a List underneath a custom .safeAreaBar(edge: .top) no longer renders the progressive fade-blur. The top edge is fully transparent — scrolled rows pass under the bar with no visual treatment at all, as if scrollEdgeEffectDisabled() had been applied. What I've verified so far: .hard renders correctly in the exact same hierarchy; only .soft is affected. The same binary works correctly on iOS 26.x Xcode preview. I'm building with Xcode 26.3 (iOS 26 SDK). Minimal reproduction: import SwiftUI struct EdgeEffectRepro: View { enum Style: String, CaseIterable, Identifiable { case automatic, soft, hard var id: Self { self } var value: ScrollEdgeEffectStyle { switch self { case .automatic: .automatic case .soft: .soft case .hard: .hard } } } @State private var style: Style = .soft @State private var useSystemBarOnly = false var body: some View { NavigationStack { List(0..<60, id: \.self) { i in Text("Row \(i)") .frame(maxWidth: .infinity, alignment: .leading) .listRowBackground( i.isMultiple(of: 2) ? Color.orange.opacity(0.45) : Color.teal.opacity(0.45) ) } .scrollIndicators(.hidden) .scrollEdgeEffectStyle(style.value, for: .top) .safeAreaBar(edge: .top) { if !useSystemBarOnly { VStack(spacing: 8) { HStack { Text("Custom Top Bar") .font(.system(size: 28, weight: .bold)) Spacer() } HStack { Text("Second row (e.g. date range picker)") .font(.caption) .foregroundStyle(.secondary) Spacer() } } .padding(.horizontal) } } .safeAreaInset(edge: .bottom) { VStack(spacing: 8) { Picker("Edge effect style", selection: $style) { ForEach(Style.allCases) { Text($0.rawValue).tag($0) } } .pickerStyle(.segmented) Toggle("System bar only (control group)", isOn: $useSystemBarOnly) .font(.caption) } .padding() .background(.regularMaterial) } .navigationTitle("EdgeEffect Repro") .navigationBarTitleDisplayMode(.inline) } } } Steps: run on iOS 27 beta 1, set the picker to soft, scroll rows under the bar. Expected: fade-blur as on iOS 26. Actual: fully transparent. Switch to hard: renders fine.
3
7
508
3d
Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
Xcode tells me Previewing in executable targets now requires a new build layout for unoptimized builds. Either set ENABLE_DEBUG_DYLIB to YES for this target, or break out your preview code into a separate framework with its own scheme. How do enable that in Package.swift. swiftSettings don't work (.define and unsafeFlags with -D ...). Creating a library product that the executable then depends on doesn't help either. I have two targets, one is an executable target. The #Preview macro is in the non-executable target.
4
2
467
3d
How Did Apple Create the Fitness App Awards Animation?
Open your Apple Fitness app, I am facinated by the animation of the Awards screen, it is so smooth. Any idea how this was transiton created from a Grid/CollectionView to a RealityView? I assume the interative badge is a RealityView with a 3D model in there, but how the hell the transition was so smooth from the parent list screen to the detail screen.
0
0
56
3d
Pass data to an @Observable model
Overview I have a navigation split view. The detail view contains a model now this model depends on id from the parent view. Questions How can I pass data from the parent view and yet create the view in the detail view? Or should I be pass the model from the parent view, but the problem is the parent view needs to persist model. Or is there a better approach?
6
0
207
4d
NavigationStack has no animations or back gesture in macOS
When running a native macOS app using SwiftUI and a NavigationStack, clicking any links causes the contents of the stack to change immediately with no animation, and you can't use the usual two-finger swipe gesture to go back. The behavior is correct when running it as a Mac Catalyst app, you get the animated transitions when navigating, and swiping works. Minimal Example: (put this directly inside the WindowGroup) NavigationStack { VStack { NavigationLink { Rectangle().foregroundStyle(.red) } label: { Text("Button") } } }
0
0
50
4d
SwiftUI Slider onEditingChanged is unreliable on iOS 26
For information I stumbled upon a regression with SwiftUI Slider on iOS 26. Its onEditingChanged closure might be called twice when interaction ends, with a final Boolean incorrect value of true provided to the closure. As a result apps cannot reliably rely on this closure to detect when an interaction with the slider starts or ends. I filed a feedback under FB20283439 (iOS 26.0 regression: Slider onEditingChanged closure is unreliable).
8
10
648
5d
Cannot download voices in the iOS 26.5 Simulator
The issue can be reproduced as follows : Launch the iOS 26.5 Simulator. Go to the Settings app. Tap Accessibility. Tap Spoken Content. Turn on Speak Selection. Tap Voices. An empty view gets opened, in which no language can be selected. How can voices be downloaded in the iOS 26.5 Simulator ? Note: There is not such issue in the iOS 18.5 Simulator. Note: There is not such issue in a real iOS 26.5 Device.
2
0
144
1w
requestReview() prompting repeatedly
We're getting user reports that the App Store rating prompt appears repeatedly — one user says they're prompted roughly every day, and that they still get the prompt after they've already left a rating. This contradicts the documented behavior, so I want to check whether others are seeing the same thing or whether there's a known regression. What the docs say should happen The system limits display to 3 occurrences per app within a 365-day period. For a user who has already rated/reviewed, StoreKit should only display again if the app version is new and more than 365 days have passed since their previous review. Has anyone else experience it?
0
0
172
1w
TextField format, integer limits and fractions not applied
Hi Apple-Team, the format of a text field, in my case a percentage with one decimal place, is not applied when a button is pressed and the view is exited using dismiss. It is only used when another field receives focus. A button is not a focusable object, and this is a problem. This allows you to specify more decimal places, resulting in a saved value with unwanted decimal places. It's even worse when you specify integer limits and the value exceeds the limit. Do you always have to check the value before saving it? What's the point of having a format then? Some example images: The items in the list have a fraction limit of 8. The field has integer limit 2 and 1 fraction. When focusing a different field the format is applied. Here the code I used: struct Item: Identifiable, Hashable { var id: Int var value: Double } struct WrongFractionsListView: View { @State private var items: [Item] = [ Item(id: 1, value: 0.225), Item(id: 2, value: 0.377), Item(id: 3, value: 0.241)] enum ItemTransfer: Hashable { case new } var body: some View { List { ForEach(items) { item in HStack { Text("\(item.id)") Spacer() Text("\(item.value, format: .percent.precision(.fractionLength(8)))") } } } .navigationDestination(for: ItemTransfer.self) { _ in WrongFractionsEditorView(items: $items) } .toolbar{ ToolbarItem(placement: .topBarTrailing) { NavigationLink(value: ItemTransfer.new) { Image(systemName: "plus") } } } } } #Preview { NavigationStack { WrongFractionsListView() } } struct WrongFractionsEditorView: View { @Environment(\.dismiss) var dismiss @State private var percentValue: Double = 0 @State private var testValue: String = "" @Binding var items: [Item] var body: some View { Form { TextField("(%)", value: $percentValue, format: .percent.precision(.integerAndFractionLength(integerLimits: 0...2, fractionLimits: 0...1))) .keyboardType(.decimalPad) TextField("Just for Focus", text: $testValue) } .navigationTitle("Percent Fractions") .toolbar{ ToolbarItem(placement: .topBarTrailing) { Button { saveAndClose() } label: { Image(systemName: "checkmark") } } } } private func saveAndClose() { let max = items.max { $0.id < $1.id}!.id let item: Item = .init(id: max+1, value: percentValue) items.append(item) dismiss() } } #Preview { @Previewable @State var items: [Item] = [ Item(id: 1, value: 0.225), Item(id: 2, value: 0.377), Item(id: 3, value: 0.241)] NavigationStack { WrongFractionsEditorView(items: $items) } } How can I fix this? Thank you Christian
2
0
125
1w
Did VisionOS27 get the LazyVGrid Performance Updates?
Did VisionOS get the LazyVGrid Performance Updates that other platforms received? I’m observing that a LazyVGrid that works well on iPhone, iPad, and Mac appears to hitch and jitter as cells exit and renter the lazyVGrid on VisionOS. It really feels like it did not get the same behavior changes as the other platforms. I observe the scrollbar expands as cells leave the top of the grid, and each “exit” of a row seems to cause a hitch. I’ve got rigidly defined cell frames, rigidly defined columns. I don’t think any cells frames are being invalidated during scroll… (there’s no way to check this with instruments, right?) I‘ve made several analysis passes myself and threw the Xcode Agent with Codex at it just to scan for stuff, but it’s starting to just guess at things. Any known issues with VisionOS?
Replies
3
Boosts
0
Views
59
Activity
2h
Changing a State var in a Timer block doesn't update the UI
Can anyone explain to me why my UI doesn't update after the timer fires in this code below? Even when the timer fires, the UI doesn't update. thanks, in advance for any guidance Mike struct ContentView: View { @State var referenceDate: Date = Date() init () { setupTimer() } func setupTimer() { let calendar = Calendar.current guard let triggerDate = calendar.nextDate( after: Date(), matching: DateComponents(hour: 14, minute: 46, second: 0), matchingPolicy: .nextTime ) else { return } let timer = Timer(fire: triggerDate, interval: 0.2, repeats: false) { _ in self.referenceDate = Date() print("runLoop!") } RunLoop.main.add(timer, forMode: .common) } var body: some View { VStack { Text("Ref time: \(referenceDate.formatted(date: .abbreviated, time: .standard))") } } }
Replies
2
Boosts
0
Views
52
Activity
1d
How to get the correct animation when inserting/removing a row in a SwiftUI List from a swipeAction?
Hello, In my app, I have a List with two sections. The first section contains favourited items. The second section contains all the items. I use a swipeAction to favorite / undo favorite an item. An item can be in the first section and in the second section. But when I use the swipeAction to perform the action, the row animation is conflicting with the List animation for insertion / removal (I think). It’s not synchronised and it leads to an ugly UX. GeometryGroup on the Section does not help. One solution is to delay the action so the swipe has enough time to go back to its original position but it’s hacky and depends too much on manual timing, etc. If I favorite / undo from a tap on the row (no swipe action), the animation is correct (obviously, as the row doesn’t need to animate to its original position). I experimented with a ScrollView + swipeActionsContainer() + swipeActions on iOS 27, and it works very nicely. But this solution only works for iOS 27 and my app targets iOS 18. So I would love to have a native implementation for iOS 18+ if possible. Am I missing something to get the correct animation with a List? You can check the attached code: https://gist.github.com/alpennec/f9de25cda29b515eb45af6b368a89ed8 Video: https://www.dropbox.com/scl/fi/sqitivihm4pbu8htxicap/ListSectionsSwipeActions.mov?rlkey=08wl708g82rmyy6nkf75725bv&st=0qb7rhdd&dl=0 I also filed a feedback with a video: FB23661327 Regards, Axel
Replies
1
Boosts
1
Views
46
Activity
1d
Drag and Drop stopped working after upgrading from macOS 15 to 26
When I drag and drop a file with flag "shouldAttemptToOpenInPlace: true", I was able to access the original file name in macOS 15. After upgrading to macOS 26, I can't access the original file name anymore. Instead, I got some useless file name such as ".com.apple.Foundation.NSItemProvider.gKZ91u.tmp". The app no longer works with these tmp filenames because it needs the orignal file name to do the file transfer. (Btw, this is a WinSCP like app on Mac platform) Could you please check and fix this issue? Thank you. FileRepresentation(contentType: .item, shouldAttemptToOpenInPlace: true)
Replies
2
Boosts
0
Views
477
Activity
1d
How can a SwiftUI drag provide the actual file URL of an existing file on macOS (as NSOutlineView does)?
I'm dragging existing files from a SwiftUI List (a search result list in a sandboxed, document-based Mac app), and I want drop targets to receive the actual file URL — the same behavior as AppKit's NSOutlineView with outlineView(_:pasteboardWriterForItem:) returning an NSURL: the Finder copies the file, browsers load it, and text views insert its path. My current implementation is Transferable-based: FileRepresentation(exportedContentType: .data) { item in SentTransferredFile(item.fileURL, allowAccessingOriginalFile: true) } .suggestedFileName(\.fileURL.lastPathComponent) With this, what receivers get is a temporary copy in the app's own container (Caches/com.apple.SwiftUI.Drag-<UUID>/), not the actual file URL — despite allowAccessingOriginalFile: true. Dropping on the Finder or onto an application icon works through the copy, but receivers that interpret the URL itself — a browser window, or a text view that inserts the dropped file's path — see the temporary container path. Note that the dragged files live inside a folder the user has opened as a document (the app is NSDocument-based), so the app already holds security-scoped access to them. Alternatives don't help either: DataRepresentation(exportedContentType: .fileURL) returning the URL bytes of the actual file: the pasteboard data is likewise replaced with the copy's URL, and moreover, drops onto application icons (e.g. Safari in the Dock) are no longer accepted at all. onDrag with NSItemProvider(object: url as NSURL): same substitution. I've already filed this as FB23578716, with detailed reproduction steps and drag-pasteboard dumps. My questions: Is there any way in current SwiftUI (macOS 26/27 SDK) to put the real file URL of an existing file on the drag pasteboard? Is the rewriting to a temporary copy intended behavior (for sandbox safety), or a bug? If it's intended, is embedding an AppKit view that calls beginDraggingSession(with:event:source:) with an NSURL pasteboard writer the recommended workaround for now? It does write the real URL, but making it coexist with List's selection and click handling has proven fragile. Environment: macOS: macOS 27 Beta 2 / Version 26.5.2 Xcode: Version 27.0 Beta 2 App Sandbox enabled
Replies
3
Boosts
0
Views
113
Activity
2d
SwiftUI ​Charts: In iOS 27, annotation overlays exceed the bounds of an annotation
I'm seeing a regression in SwiftUI Charts on iOS 27 beta 1. Any view placed inside a BarMark's overlay annotation no longer receives the size of the parent BarMark. It collapses to zero, so any content sized from geo.size (e.g. a Rectangle meant to fill the bar) renders empty or incorrectly. Expected: The GeometryReader reports the BarMark's rendered width/height, and the Rectangle fills the BarMark (this is the behavior in iOS 26 and earlier). Actual: On iOS 27 beta 1, geo.size is effectively zero, so the overlay content has an extremely small size. I suspect this could be a small bug with the new ContentBuilder / ViewBuilder changes but that's just a hunch. Here's a code sample which reproduces the issue. // MARK: - Mock Data Models struct ScheduleSeries: Identifiable { let id = UUID() let data: [ScheduleItem] } struct ScheduleItem: Identifiable { let id = UUID() let startDate: Date let startHour: Double let endHour: Double let secondaryText: String? } // MARK: - Minimal Reproducible Example struct ContentView: View { // Generate two consecutive days for the mock data let mockSchedule: [ScheduleSeries] = [ ScheduleSeries(data: [ ScheduleItem( startDate: Date(), startHour: 9.0, endHour: 11.5, secondaryText: "Morning Event" ), ScheduleItem( startDate: Calendar.current.date(byAdding: .day, value: 1, to: Date())!, startHour: 13.0, endHour: 16.0, secondaryText: "Afternoon Event" ) ]) ] var body: some View { VStack(alignment: .leading) { Text("FB: Annotation Sizing Bug") .font(.headline) .padding(.bottom, 8) Text("Expected: The gray Rectangle should stretch to fill the BarMark.\nActual: GeometryReader/Annotation fails to size to the parent BarMark.") .font(.caption) .foregroundColor(.secondary) .padding(.bottom) Chart(mockSchedule) { series in ForEach(series.data, id: \.startDate) { element in BarMark( x: .value("Day", element.startDate, unit: .day, calendar: .current), yStart: .value("Start", element.startHour), yEnd: .value("End", element.endHour), width: .ratio(0.99) ) .annotation(position: .overlay, alignment: .topLeading) { item in ZStack { VStack(alignment: .leading, spacing: 0) { // BUG DEMONSTRATION: // This GeometryReader and Rectangle previously filled the BarMark, but in Xcode 27 it does not GeometryReader { geo in Rectangle() .fill(Color.black.opacity(0.15)) .frame(width: geo.size.width, height: geo.size.height) } } .foregroundColor(.white) .font(.caption2) } } } } .chartYScale(domain: 0...24) // Lock the Y-axis to a 24-hour scale } .padding() } } Environment: Xcode 27 beta 1 / iOS 27 beta 1 Reproduces on device and Simulator Worked as expected on iOS 26 and earlier Here's what the issue looks like in our app with zero code changes: iOS 26 iOS 27 I've filed a feedback report (FB23016343) with a sample project attached. Has anyone else hit this, or found a workaround for sizing overlay annotation content to a BarMark in iOS 27? Thanks!
Replies
2
Boosts
0
Views
161
Activity
2d
Using `containerRelativeFrame` in a `List` on macOS leads to crash
The following code crashes as soon as the app launches. struct ContentView: View { var body: some View { List { Rectangle() .fill(.red) .containerRelativeFrame([.horizontal, .vertical]) } .frame(width: 400, height: 800) } } I would expect the code not to crash. Note that using a ScrollView works perfectly fine: struct ContentView: View { var body: some View { ScrollView { Rectangle() .fill(.red) .containerRelativeFrame([.horizontal, .vertical]) } .frame(width: 400, height: 800) } } The documentation clearly stipulates that it should work with a list: A scrollable view like ScrollView or List Using Xcode 26.5 (17F42) and simply created a new macOS project using SwiftUI. Feedback FB23655564
Replies
1
Boosts
0
Views
48
Activity
2d
SwiftUI confirmationDialog in List inside .sheet is no longer anchored to the originating row on iOS 27 beta
Area SwiftUI → Presentation / ConfirmationDialog Summary After building with Xcode 27 beta, confirmationDialog presented from a row inside a List that is embedded in a .sheet is no longer anchored to the row that triggered it. Instead, the dialog is displayed near the top of the sheet when the sheet is partially expanded, or in the center of the screen when the sheet occupies the full height. This behavior is reproducible across all tested Xcode 27 beta releases and iOS 27 beta releases (Beta 1, Beta 2, and Beta 3). Steps to Reproduce Present a SwiftUI .sheet. Place a List inside the sheet. Add a confirmationDialog to each list row. Trigger the dialog from a swipe action on any row. Observe the position where the confirmation dialog appears. A minimal reproducible sample project is attached. Expected Result The confirmationDialog should be visually associated with the row that triggered it, as it behaved in previous Xcode and iOS releases. The dialog should appear anchored to the selected list row (or as close as the platform allows), providing clear contextual feedback to the user about which item is being acted upon. Actual Result The dialog is no longer associated with the selected row. When the sheet is not fully expanded, the dialog appears near the top area of the sheet, seemingly positioned relative to the sheet itself rather than the triggering row. When the sheet is expanded to full height, the dialog appears in the center of the screen. As a result, the relationship between the selected item and the confirmation dialog is lost, creating a confusing user experience. Regression Yes. The same implementation behaved correctly in previous Xcode and iOS versions. The issue first appeared after upgrading to Xcode 27 beta and remains present in all tested iOS 27 beta releases (Beta 1–3). Impact This is a significant UX regression for existing applications that rely on contextual confirmation dialogs within lists presented inside sheets. Applications that already have production users cannot easily redesign their interaction model to compensate for this behavior change. The previous behavior provided clear context about which list item was being acted upon, while the current behavior makes that association unclear. Configuration Xcode 27 Beta (all tested beta versions) iOS 27 Beta 1 iOS 27 Beta 2 iOS 27 Beta 3 Reproduced on physical devices Reproduced using the attached minimal sample project Attachments Minimal reproducible sample project. Screenshot showing expected behavior (prior implementation). Screenshot showing current behavior on iOS 27 Beta 3. Screen recording demonstrating the regression. struct ContentView: View { @State private var sheetIsPresented = false @State private var itemPendingDeletion: Int? = nil var array = Array(0...100) var body: some View { VStack { Text("Hello, world!") Button("Show List") { sheetIsPresented = true } } .sheet(isPresented: $sheetIsPresented) { List { ForEach(array, id: \.self) { value in ListRow(for: value) .confirmationDialog("Delete?", isPresented: Binding( get: { itemPendingDeletion == value }, set: { isPresented in if !isPresented { itemPendingDeletion = nil } } ) ) { Button { } label: { Text("Delete") } } .swipeActions(edge: .trailing) { Button { itemPendingDeletion = value } label: { Image(systemName: "trash") .foregroundStyle(.red) } } } .listRowInsets(EdgeInsets()) .listRowBackground(Color.clear) } .listStyle(.inset) .contentMargins(16, for: .scrollContent) .presentationDetents([.fraction(1), .fraction(0.9)]) } } @ViewBuilder private func ListRow(for value: Int) -> some View { Text("\(value)") .foregroundStyle(.primary) .padding(.vertical) .frame(maxWidth: .infinity) .background( RoundedRectangle(cornerRadius: 26, style: .continuous) ) .padding(.vertical, 2) } } #Preview { ContentView() } Xcode 27(Beta 1,2,3) Xcode 26.5
Replies
0
Boosts
0
Views
49
Activity
3d
SwiftUI confirmationDialog in List inside .sheet is no longer anchored to the originating row on iOS 27 beta
Area SwiftUI → Presentation / ConfirmationDialog Summary After building with Xcode 27 beta, confirmationDialog presented from a row inside a List that is embedded in a .sheet is no longer anchored to the row that triggered it. Instead, the dialog is displayed near the top of the sheet when the sheet is partially expanded, or in the center of the screen when the sheet occupies the full height. This behavior is reproducible across all tested Xcode 27 beta releases and iOS 27 beta releases (Beta 1, Beta 2, and Beta 3). Steps to Reproduce Present a SwiftUI .sheet. Place a List inside the sheet. Add a confirmationDialog to each list row. Trigger the dialog from a swipe action on any row. Observe the position where the confirmation dialog appears. A minimal reproducible sample project is attached. Expected Result The confirmationDialog should be visually associated with the row that triggered it, as it behaved in previous Xcode and iOS releases. The dialog should appear anchored to the selected list row (or as close as the platform allows), providing clear contextual feedback to the user about which item is being acted upon. Actual Result The dialog is no longer associated with the selected row. When the sheet is not fully expanded, the dialog appears near the top area of the sheet, seemingly positioned relative to the sheet itself rather than the triggering row. When the sheet is expanded to full height, the dialog appears in the center of the screen. As a result, the relationship between the selected item and the confirmation dialog is lost, creating a confusing user experience. Regression Yes. The same implementation behaved correctly in previous Xcode and iOS versions. The issue first appeared after upgrading to Xcode 27 beta and remains present in all tested iOS 27 beta releases (Beta 1–3). Impact This is a significant UX regression for existing applications that rely on contextual confirmation dialogs within lists presented inside sheets. Applications that already have production users cannot easily redesign their interaction model to compensate for this behavior change. The previous behavior provided clear context about which list item was being acted upon, while the current behavior makes that association unclear. Configuration Xcode 27 Beta (all tested beta versions) iOS 27 Beta 1 iOS 27 Beta 2 iOS 27 Beta 3 Reproduced on physical devices Reproduced using the attached minimal sample project Attachments Minimal reproducible sample project. Screenshot showing expected behavior (prior implementation). Screenshot showing current behavior on iOS 27 Beta 3. Screen recording demonstrating the regression. struct ContentView: View { @State private var sheetIsPresented = false @State private var itemPendingDeletion: Int? = nil var array = Array(0...100) var body: some View { VStack { Text("Hello, world!") Button("Show List") { sheetIsPresented = true } } .sheet(isPresented: $sheetIsPresented) { List { ForEach(array, id: \.self) { value in ListRow(for: value) .confirmationDialog("Delete?", isPresented: Binding( get: { itemPendingDeletion == value }, set: { isPresented in if !isPresented { itemPendingDeletion = nil } } ) ) { Button { } label: { Text("Delete") } } .swipeActions(edge: .trailing) { Button { itemPendingDeletion = value } label: { Image(systemName: "trash") .foregroundStyle(.red) } } } .listRowInsets(EdgeInsets()) .listRowBackground(Color.clear) } .listStyle(.inset) .contentMargins(16, for: .scrollContent) .presentationDetents([.fraction(1), .fraction(0.9)]) } } @ViewBuilder private func ListRow(for value: Int) -> some View { Text("\(value)") .foregroundStyle(.primary) .padding(.vertical) .frame(maxWidth: .infinity) .background( RoundedRectangle(cornerRadius: 26, style: .continuous) ) .padding(.vertical, 2) } } #Preview { ContentView() } Xcode 27(Beta 1,2,3) Xcode 26.5
Replies
0
Boosts
0
Views
32
Activity
3d
Adaptive Layouts iOS 27
I was experimenting with existing APIs using a NavigationSplitView and noticed that in the SwiftUI preview, resizing causes the component to switch between the content view and the sidebar. However, with the new DeviceHub tool, the app doesn’t detect the new size and stays in the content view. Is this expected? I would expect Navigation Split View to handle size changes automatically. Is this expected behaviour? FB23340323
Replies
3
Boosts
0
Views
164
Activity
3d
iOS 27 beta 1: .scrollEdgeEffectStyle(.soft) renders fully transparent above safeAreaBar
Feedback ID: FB23086400 On iOS 27 beta 1, .scrollEdgeEffectStyle(.soft, for: .top) on a List underneath a custom .safeAreaBar(edge: .top) no longer renders the progressive fade-blur. The top edge is fully transparent — scrolled rows pass under the bar with no visual treatment at all, as if scrollEdgeEffectDisabled() had been applied. What I've verified so far: .hard renders correctly in the exact same hierarchy; only .soft is affected. The same binary works correctly on iOS 26.x Xcode preview. I'm building with Xcode 26.3 (iOS 26 SDK). Minimal reproduction: import SwiftUI struct EdgeEffectRepro: View { enum Style: String, CaseIterable, Identifiable { case automatic, soft, hard var id: Self { self } var value: ScrollEdgeEffectStyle { switch self { case .automatic: .automatic case .soft: .soft case .hard: .hard } } } @State private var style: Style = .soft @State private var useSystemBarOnly = false var body: some View { NavigationStack { List(0..<60, id: \.self) { i in Text("Row \(i)") .frame(maxWidth: .infinity, alignment: .leading) .listRowBackground( i.isMultiple(of: 2) ? Color.orange.opacity(0.45) : Color.teal.opacity(0.45) ) } .scrollIndicators(.hidden) .scrollEdgeEffectStyle(style.value, for: .top) .safeAreaBar(edge: .top) { if !useSystemBarOnly { VStack(spacing: 8) { HStack { Text("Custom Top Bar") .font(.system(size: 28, weight: .bold)) Spacer() } HStack { Text("Second row (e.g. date range picker)") .font(.caption) .foregroundStyle(.secondary) Spacer() } } .padding(.horizontal) } } .safeAreaInset(edge: .bottom) { VStack(spacing: 8) { Picker("Edge effect style", selection: $style) { ForEach(Style.allCases) { Text($0.rawValue).tag($0) } } .pickerStyle(.segmented) Toggle("System bar only (control group)", isOn: $useSystemBarOnly) .font(.caption) } .padding() .background(.regularMaterial) } .navigationTitle("EdgeEffect Repro") .navigationBarTitleDisplayMode(.inline) } } } Steps: run on iOS 27 beta 1, set the picker to soft, scroll rows under the bar. Expected: fade-blur as on iOS 26. Actual: fully transparent. Switch to hard: renders fine.
Replies
3
Boosts
7
Views
508
Activity
3d
Bug: Xcode 26.2 wants `ENABLE_DEBUG_DYLIB`: How do I enable that in `Package.swift`?
Xcode tells me Previewing in executable targets now requires a new build layout for unoptimized builds. Either set ENABLE_DEBUG_DYLIB to YES for this target, or break out your preview code into a separate framework with its own scheme. How do enable that in Package.swift. swiftSettings don't work (.define and unsafeFlags with -D ...). Creating a library product that the executable then depends on doesn't help either. I have two targets, one is an executable target. The #Preview macro is in the non-executable target.
Replies
4
Boosts
2
Views
467
Activity
3d
How Did Apple Create the Fitness App Awards Animation?
Open your Apple Fitness app, I am facinated by the animation of the Awards screen, it is so smooth. Any idea how this was transiton created from a Grid/CollectionView to a RealityView? I assume the interative badge is a RealityView with a 3D model in there, but how the hell the transition was so smooth from the parent list screen to the detail screen.
Replies
0
Boosts
0
Views
56
Activity
3d
Pass data to an @Observable model
Overview I have a navigation split view. The detail view contains a model now this model depends on id from the parent view. Questions How can I pass data from the parent view and yet create the view in the detail view? Or should I be pass the model from the parent view, but the problem is the parent view needs to persist model. Or is there a better approach?
Replies
6
Boosts
0
Views
207
Activity
4d
NavigationStack has no animations or back gesture in macOS
When running a native macOS app using SwiftUI and a NavigationStack, clicking any links causes the contents of the stack to change immediately with no animation, and you can't use the usual two-finger swipe gesture to go back. The behavior is correct when running it as a Mac Catalyst app, you get the animated transitions when navigating, and swiping works. Minimal Example: (put this directly inside the WindowGroup) NavigationStack { VStack { NavigationLink { Rectangle().foregroundStyle(.red) } label: { Text("Button") } } }
Replies
0
Boosts
0
Views
50
Activity
4d
SwiftUI Slider onEditingChanged is unreliable on iOS 26
For information I stumbled upon a regression with SwiftUI Slider on iOS 26. Its onEditingChanged closure might be called twice when interaction ends, with a final Boolean incorrect value of true provided to the closure. As a result apps cannot reliably rely on this closure to detect when an interaction with the slider starts or ends. I filed a feedback under FB20283439 (iOS 26.0 regression: Slider onEditingChanged closure is unreliable).
Replies
8
Boosts
10
Views
648
Activity
5d
Cannot download voices in the iOS 26.5 Simulator
The issue can be reproduced as follows : Launch the iOS 26.5 Simulator. Go to the Settings app. Tap Accessibility. Tap Spoken Content. Turn on Speak Selection. Tap Voices. An empty view gets opened, in which no language can be selected. How can voices be downloaded in the iOS 26.5 Simulator ? Note: There is not such issue in the iOS 18.5 Simulator. Note: There is not such issue in a real iOS 26.5 Device.
Replies
2
Boosts
0
Views
144
Activity
1w
requestReview() prompting repeatedly
We're getting user reports that the App Store rating prompt appears repeatedly — one user says they're prompted roughly every day, and that they still get the prompt after they've already left a rating. This contradicts the documented behavior, so I want to check whether others are seeing the same thing or whether there's a known regression. What the docs say should happen The system limits display to 3 occurrences per app within a 365-day period. For a user who has already rated/reviewed, StoreKit should only display again if the app version is new and more than 365 days have passed since their previous review. Has anyone else experience it?
Replies
0
Boosts
0
Views
172
Activity
1w
onChange(of:initial:_:) changes when same value assigned
Overview When calling onChange(of:initial:_:) with initial as true, closure called even when the value assigned is the same as previous value (not just the first time, subsequently too). However when initial value is false it is called only when value changes. Questions Is this a bug? Am I missing something?
Replies
1
Boosts
0
Views
188
Activity
1w
TextField format, integer limits and fractions not applied
Hi Apple-Team, the format of a text field, in my case a percentage with one decimal place, is not applied when a button is pressed and the view is exited using dismiss. It is only used when another field receives focus. A button is not a focusable object, and this is a problem. This allows you to specify more decimal places, resulting in a saved value with unwanted decimal places. It's even worse when you specify integer limits and the value exceeds the limit. Do you always have to check the value before saving it? What's the point of having a format then? Some example images: The items in the list have a fraction limit of 8. The field has integer limit 2 and 1 fraction. When focusing a different field the format is applied. Here the code I used: struct Item: Identifiable, Hashable { var id: Int var value: Double } struct WrongFractionsListView: View { @State private var items: [Item] = [ Item(id: 1, value: 0.225), Item(id: 2, value: 0.377), Item(id: 3, value: 0.241)] enum ItemTransfer: Hashable { case new } var body: some View { List { ForEach(items) { item in HStack { Text("\(item.id)") Spacer() Text("\(item.value, format: .percent.precision(.fractionLength(8)))") } } } .navigationDestination(for: ItemTransfer.self) { _ in WrongFractionsEditorView(items: $items) } .toolbar{ ToolbarItem(placement: .topBarTrailing) { NavigationLink(value: ItemTransfer.new) { Image(systemName: "plus") } } } } } #Preview { NavigationStack { WrongFractionsListView() } } struct WrongFractionsEditorView: View { @Environment(\.dismiss) var dismiss @State private var percentValue: Double = 0 @State private var testValue: String = "" @Binding var items: [Item] var body: some View { Form { TextField("(%)", value: $percentValue, format: .percent.precision(.integerAndFractionLength(integerLimits: 0...2, fractionLimits: 0...1))) .keyboardType(.decimalPad) TextField("Just for Focus", text: $testValue) } .navigationTitle("Percent Fractions") .toolbar{ ToolbarItem(placement: .topBarTrailing) { Button { saveAndClose() } label: { Image(systemName: "checkmark") } } } } private func saveAndClose() { let max = items.max { $0.id < $1.id}!.id let item: Item = .init(id: max+1, value: percentValue) items.append(item) dismiss() } } #Preview { @Previewable @State var items: [Item] = [ Item(id: 1, value: 0.225), Item(id: 2, value: 0.377), Item(id: 3, value: 0.241)] NavigationStack { WrongFractionsEditorView(items: $items) } } How can I fix this? Thank you Christian
Replies
2
Boosts
0
Views
125
Activity
1w