Created a brand new project with Xcode 12 beta 3. The following code, where I've swapped in for ContentView, works in Xcode 11, but not now. The problem is the List does not go into Edit mode. Cells bounce, but no remove icon (-) appears. The EditButton does change to "Done".
However, one can take any other action - add a cell with the "Add Item" button, or just swiping a cell to reveal "Delete" (don't have to actually delete). After the List has been "kicked" into action, the EditButton will now behave properly.
struct ContentView: View {
@State var myArray : [String] = ["One", "Two", "Three"]
func removeItems(at offsets: IndexSet) {
for index in offsets {
myArray.remove(at: index)
}
}
var body: some View {
NavigationView {
VStack {
Button(action: {
self.myArray.append("Other")
}) {
Text("Insert item")
}
List {
ForEach(myArray, id: \.self) { item in
VStack {
Text(item)
}
}.onDelete(perform: removeItems(at:))
}
}
.navigationBarItems(trailing: EditButton())
.navigationBarTitle("Navigation")
}
}
}
However, one can take any other action - add a cell with the "Add Item" button, or just swiping a cell to reveal "Delete" (don't have to actually delete). After the List has been "kicked" into action, the EditButton will now behave properly.
struct ContentView: View {
@State var myArray : [String] = ["One", "Two", "Three"]
func removeItems(at offsets: IndexSet) {
for index in offsets {
myArray.remove(at: index)
}
}
var body: some View {
NavigationView {
VStack {
Button(action: {
self.myArray.append("Other")
}) {
Text("Insert item")
}
List {
ForEach(myArray, id: \.self) { item in
VStack {
Text(item)
}
}.onDelete(perform: removeItems(at:))
}
}
.navigationBarItems(trailing: EditButton())
.navigationBarTitle("Navigation")
}
}
}
I think the issue you are describing is resolved in beta 4, which was released today. I can reproduce in beta 3 but not beta 4.
If you are still seeing an issue in beta 4, or for other issues like this, consider filing a bug report using Feedback Assistant.
If you are still seeing an issue in beta 4, or for other issues like this, consider filing a bug report using Feedback Assistant.