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

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 RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more 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.