Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
SwiftUI Picker greyed out in a List

Does anyone have a fix for this? I have a Picker in my List that doesn't respond to any user input and is greyed out, but if I move it out of the List and into a VStack it functions normally.

The majority of answers I've found to this question all say that the Picker needs to be in a Form to work (which I don't understand since it works fine in a VStack), or that its a bug in which it only works on a physical device, which I've also tested on and gotten the same result.

I'll provide a screenshot as well as the code I'm using below

Picker in simulator

import SwiftUI
struct SettingsView: View {
    
@Binding var age : Int

var body: some View {
        VStack(alignment: .leading){
                List{  
                        Picker("Your age", selection: $age) {
                                ForEach(1...100, id: \.self) { number in
                                    Text("\(number)")
                                           }
                                }
                    }
        }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You must embed your List inside a NavigationView, so you can actually "navigate" from "Your age" to the list of Ints.

Just add one additional layer, as shown below:

    var body: some View {
        VStack(alignment: .leading){
            NavigationView {   // This is needed to navigate to the ForEach
                List {
                    Picker("Your age", selection: $age) {
                        ForEach(1..<101) { number in
                            Text("\(number)")
                        }
                    }
                }
            }
        }
    }
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda