I don't know why the picker is not working inside of a form in Swift UI. The app will be crashing if the user is going to tap for the second time. The console will print the following output:
[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window).
struct ContentView: View {
@State private var countryIndex = 0
var countries = ["US", "Germany", "Korea", "Russia"]
var body: some View {
NavigationView {
Form {
Section {
Picker(selection: $countryIndex, label: Text("Country")) {
ForEach(0 ..< countries.count) {
Text(self.countries[$0]).tag($0)
}
}
}
.navigationBarTitle(Text("Country"))
}
}
}
}