I'm just getting started with Swift/SwiftUI and iOS in general, so I have a long way to go, but I've been looking at the CoreData sample project, and I want to change it from using a NavigationView to a NavigationStack.
So like this...
var body: some View {
NavigationStack {
List {
ForEach(items) { item in
NavigationLink {
Text("Item at \(item.timestamp!, formatter: itemFormatter)")
} label: {
Text(item.timestamp!, formatter: itemFormatter)
}
}
.onDelete(perform: deleteItems)
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
EditButton()
}
ToolbarItem {
Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
}
}
Text("Select an item")
}
}
But when I do that, and you tap on on the list, it takes 10 taps of the 'back' button to get back to the list again. So I presume its pushing 10 views onto the stack? But how would I change that, so it only pushes the current view onto the stack, so tapping 'back' the once, takes you straight back to the list? Thanks for any help.