SwiftUI Picker doesn't use NavigationView

Hi, when I try to use Picker inside a Form, inside a NavigationView it will always use the .menu style for the Picker. All tutorials, docs show the default renderings to have a new nav page rendered with the options.

I don't want this 'dropdown', I want my pickers to behave the same way they do in iOS system settings (new subpage with navigation).

I'm using the latest xcode, creating for iOS.

struct SettingsView: View {
  @Binging var colorScheme: ColorScheme?
  @State var selectedColorScheme: Int = 1
   
  var body: some View {
    NavigationView {
      Form {
        Section(header: Text("UI").foregroundColor(.secondary)) {
          Picker("Color scheme", selection: $selectedColorScheme) {
            Text("system default").tag(1)
            Text("light theme").tag(2)
            Text("dark theme").tag(3)
           }.onChange(of: selectedColorScheme) { scheme in
            switch scheme {
            case 1:
              colorScheme = nil
            case 2:
              colorScheme = .light
            case 3:
              colorScheme = .dark
            default:
              break
            }
          }
      }
    }
  }
}
Answered by BabyJ in 736781022

I believe in iOS 16.1 this feature was put back in SwiftUI, but in the form of a new picker style (since the default is .menu). It's called .navigationLink and is available from iOS 16.0.

Hi, you can use the pickerStyle(_:) view modifier to force the picker to behave as you like. With the .automatic option, the picker style is chosen based on the platform and the number of options available.

Accepted Answer

I believe in iOS 16.1 this feature was put back in SwiftUI, but in the form of a new picker style (since the default is .menu). It's called .navigationLink and is available from iOS 16.0.

SwiftUI Picker doesn't use NavigationView
 
 
Q