I have a master-detail app with a Picker control in the detail for editing a field. After picking the form cell for the picker is gray. This only happens when I use StackNavigationViewStyle: remove that and the cell reverts to normal white.
Is is a bug or my mistake? I am using Xcode 12.1, targeting iOS 14.0, building on macOS 10.15.7.
Here's some sample code.
ContentView is:
and the EditBoyView is:
If you comment out line 15 of the ContentView then the picker cell is white.
Is is a bug or my mistake? I am using Xcode 12.1, targeting iOS 14.0, building on macOS 10.15.7.
Here's some sample code.
ContentView is:
Code Block struct ContentView: View { @State private var boys = ["Arthur", "Cedric"] var body: some View { NavigationView { List { ForEach(boys, id: \.self) { boy in NavigationLink( destination: EditBoyView(boy: boy), label: { Text(boy) }) } } .navigationBarTitle("Boys") } .navigationViewStyle(StackNavigationViewStyle()) } }
and the EditBoyView is:
Code Block struct EditBoyView: View { public var boy: String @State private var name: String = "" static var boyNames = ["Arthur", "Bill", "Cedric", "Dean"] var body: some View { Form { Picker("Name", selection: $name) { ForEach(Self.boyNames, id: \.self) { choice in Text(choice) } } } .navigationBarTitle(boy, displayMode: .inline) .onAppear { if name == "" { name = boy } } } }
If you comment out line 15 of the ContentView then the picker cell is white.