This thread may provide some hints:
https://www.hackingwithswift.com/forums/swiftui/list-view-stuck-in-edit-mode/7401
It tested this, which apparently does what you need:
struct ContentView: View {
@State private var selects: Set<Int> = []
@State var range = [1, 2, 3 ,4, 5]
@Environment(\.editMode) var editMode
var body: some View {
VStack{
EditButton()
List(selection: $selects){
ForEach(range, id: \.self) {
ItemInList(num: $0)
}
.onDelete {
range.remove(atOffsets: $0)
editMode?.wrappedValue = .inactive
}
}
.listStyle(PlainListStyle())
}
}
}
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: