UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Day 16: Picker not producing same result as shown in video

Forums > 100 Days of SwiftUI


The below code is part of Day 16's example, however it does not produce the same result as shown in the accompanying video for said day which can be seen at: https://youtu.be/wBIv4QRawY0?t=141starting or on the HWS site (https://www.hackingwithswift.com/books/ios-swiftui/creating-views-in-a-loop) then manually jumping to the time stamp of 2:21

struct ContentView: View {
    let students = ["Harry", "Hermione", "Ron"]
    @State private var selectedStudent = 0

    var body: some View {
        VStack {
            Picker("Select your student", selection: $selectedStudent) {
                ForEach(0 ..< students.count) {
            Text("You chose: Student # \(students[selectedStudent])")

Has the functionality of Picker changed? In all the videos & examples I could find plus dinking around I could not get the label "Select your student" to appear in any other way than inside a Form { } & this is not the same result as in the video.

Show up every day!


I stumbled across the same thing. It appears Apple has changed the way pickers handle labels. But I have found very little actual documentation.

Perhaps Apple assumes developers will prever to manually create visual labels for pickers. But the picker label is still important for things like things like voiceover.

Since this is the very first actual project in 100 days of swiftui I hope Paul updates this because it can be very frustrating for students starting out.


Still no explanation to this ???


Yes the label do not show in the Picker unless you are in Form instead of a VStack this changed in one of the early betas of iOS 13/4, however you still need the label string as this is use with VoiceOver.

Think it was because the formatting of String did not fit very well therefore is not needed as most of the time .labelHidden(true)

If you want a label in a VStack the put Text("Select your student") before the Picker


Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.