Post

Replies

Boosts

Views

Activity

Reply to Navigation: update multiple times per frame
I encountered this problem with my NavigationStack when using both NavigationLink with values and without. The navigationStack had to be all NavigationLinks with values or without, I could not mix the two. NavigationLink(destination: ItemDetail(item: equipItem)) { Text("\(equipItem.name)") } NavigationLink with no value NavigationLink(equipItem.name, value: equipItem) .navigationTitle(categoryName) // code .... // .navigationDestination(for: equipment.self, destination: { equipItem in ItemDetail(item: equipItem) NavigationLink with a value
Apr ’23
Reply to Use alert with toolbar cause preview crash
The use of NavigationView has been deprecated. Apple states: If your app has a minimum deployment target of iOS 16, iPadOS 16, macOS 13, tvOS 16, or watchOS 9, or later, transition away from using NavigationView. In its place, use NavigationStack and NavigationSplitView instances. Try your code with NavigationStack instead. import SwiftUI struct MainView: View { @State var showingAlert = false var body: some View { NavigationStack { Button( "Tap me") { showingAlert = true } .navigationTitle("Title") .toolbar { Label("bell", systemImage: "bell") } } .alert("Alert", isPresented: $showingAlert) { Button("OK", role: .destructive) { } } } } struct MainView_Previews: PreviewProvider { static var previews: some View { MainView() } }
Mar ’23