Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI Form Picker only shows once

I am playing around with SwiftUI, and am currently building a Form using a Picker.

import SwiftUI

struct ContentView: View {
  private let names = ["Bill", "Peter", "Johan", "Kevin"]
  @State private var favoritePerson = "Bill"

  var body: some View {
    NavigationView {
      Form {
        Picker("Favorite person", selection: $favoritePerson) {
          ForEach(names, id: \.self) { name in
            Text(name)
          }
        }
      }
      .navigationBarTitle("Form", displayMode: .inline)
    }
  }
}

The first time you tap on the "Favorite person" row, the picker shows up fine, and tapping on one of the names brings you back to the form. But tapping on the form row a second time doesn't do anything: you don't go to the picker, the row stays highlighted but nothing happens. If this is a SwiftUI bug, is there a known workaround? (I already needed to use a small navigation bar title to work around the Picker UI bug where otherwise its content moves up when it's shown ☹️)

like image 296
Kevin Renskers Avatar asked Jan 01 '20 14:01

Kevin Renskers


1 Answers

this issue is just one with the simulator. If you build the app on a physical iOS device, it no longer becomes an issue. It's like that bug with Navigation Link that would only work once.

like image 60
Tahmid Azam Avatar answered Sep 27 '22 17:09

Tahmid Azam