Getting this error with SwiftUI Pickers in a Form. The error occurs when the user selects a choice in the presented choices table.
The error only occurs on my physical device (iPhone 8) running iOS 13.1: it doesn't occur with iOS 13.1 in Simulators.
Here some screens demonstrating the problem:
SwiftUI Pickers in a Form Bug Screenshots
import SwiftUI
struct ContentView: View {
@State private var selectedLanguage: Language = .en
var body: some View {
NavigationView{
Form {
List{
Picker("Choose language", selection: $selectedLanguage){
ForEach(Language.allCases, id: \.self) { lang in
HStack{
Text(lang.rawValue)
}.tag(lang)
}
}.pickerStyle(DefaultPickerStyle())
}
}
}
}
}
enum Language: String, CaseIterable {
case en = " English"
case ch = " Chinees"
case ru = " Russian"
case es = " Spain"
case se = " Sweden"
var toString: String {
return self.rawValue
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I expect checkmark working correctly on iPhone device, but I can't see any checkmark on device and get this error:
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). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window.