Post

Replies

Boosts

Views

Activity

Reply to SwiftUI EditButton problem in Xcode 12 beta
I just filed a bug with Apple about this. The problem is in adding the StackNavigationViewStyle to the NavigationView. Run the following code and note that if you immediately click the EditButton the list jumps but does not properly enter edit mode. Then comment out the marked line below and run it again: things work fine. struct ContentView: View { 		@State private var myArray: [String] = ["One", "Two", "Three"] 		var body: some View { 				NavigationView { 						List { 								ForEach(myArray, id: \.self) { item in 										Text(item) 								} 								.onDelete { indexSet in 										myArray.remove(atOffsets: indexSet) 								} 						} 						.navigationTitle("My List") 						.navigationBarItems(trailing: EditButton()) 				} 				.navigationViewStyle(StackNavigationViewStyle()) // Comment this out and the problem goes away. 		} }
Dec ’20