Post

Replies

Boosts

Views

Activity

Reply to NavigationDestination, NavigationLink with List and ForEach Does Not Work
Hi @darkpaw, Thank you for helping. The moveItems is just a function as shown below. private func moveItems(indices: IndexSet, newOffset: Int) { self.items.move(fromOffsets: indices, toOffset: newOffset) } I've shown all the code but it doesn't work for me. But I think I've found the problem, all the views like CarView(), HouseView() have their own NavigationStack and I didn't pass in the NavigationPath binding. Thanks
15h
Reply to List Rows Can Be Moved While Not Editing
Hi Sydney, Thank you very much for your reply! I have updated my code as per your advice, but it seems that the rows are still able to be moved even when the Edit button is not clicked. Below is my updated code for your reference: Thanks Best, Eugene @AppStorage("fruits") private var fruits = Fruits.fruits var body: some View { NavigationStack { VStack { List($fruits, editActions: .move) { $fruit in NavigationLink { FruitView(title: fruit.title) } label: { fruit.icon Text(fruit.title) } } .environment(\.defaultMinListRowHeight, UIElementConstants.listCellHeight) } .toolbar { EditButton() } .navigationTitle("Fruits") } } Instead of the List constructor above, I have also tried the same one from your code snippet as shown below: List($fruits, editActions: .move) { $fruit in NavigationLink(fruit.title) { FruitView(title: fruit.title) } } The second code block from my original post is untouched.
2w