GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

Day 17 - Creating pickers in a form - Error

Forums > 100 Days of SwiftUI

I get this error when I add a modifier (.navigationLink) to a Picker

Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure

var body: some View {
        NavigationStack {
            Form {
                Section {
                    TextField("Amount", value: $checkAmount, format: .currency(code: Locale.current.currency?.identifier ?? "USD"))
                        .keyboardType(.decimalPad)

                    Picker("Number of people", selection: $numberOfPeople) {
                        ForEach(2..<100) {
                            Text("\($0) people")
                        }
                    }
                    .pickerStyle(.navigationLink)
                }

                Section {
                    Text(checkAmount, format: .currency(code: Locale.current.currency?.identifier ?? "USD"))
                }
            }
        } 
    }

XCode Version 14.0.1 (14A400)

   

Using Xcode Version 15.3 (15E204a) and everything works fine. Think that you are using an old version of Xcode. Make sure that Minimum Deployment is iOS16 or higher

1      

I wish I could help you but I have just hit the same problem.

I added the pickerStyle to my code and got the following two errors.

On the Section { line there is the message - Struct 'ViewBuilder' requires that 'EmptyTableRowContent<V> conform to 'TableRowContent'

On the .keyboardType(.decimalPad) - Static method "buildExpression' requires that 'some View'. conforms to 'TableRowContent'

Maybe some one wll be able to help us both.

   

I am using the same version of Xcode and on the latest version of IOS

   

Hacking with Swift is sponsored by try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

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

Reply to this topic…

You need to create an account or log in to reply.

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.