NEW: Learn to build the incredible iOS 15 Weather app today! >>

SOLVED: Question: My decimalPad won't build

Forums > 100 Days of SwiftUI

Hello I'm on Project 1

https://www.hackingwithswift.com/books/ios-swiftui/reading-text-from-the-user-with-textfield

I'm following Paul's codes step by step. When I built through command R , my decimal keyboard don't appear when I'm trying to type. (But in Paul's demonstration his worked)

Here's my code. Is there anything wrong ?

I'm building on Simulator of iPhone 13 Pro ( iOS 15.0 )

// // ContentView.swift // WeSplit // // Created by Boat on 2/12/21. //

import SwiftUI

struct ContentView: View { @State private var checkAmount = 0.0 @State private var numberOfPeople = 2 @State private var tipPercentage = 20

let tipPercentages = [10,15,20,25,0]

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

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

}

struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }

   

When running the simulator and the text field selected, do CMD-K to bring up the keyboard.

1      

Hacking with Swift is sponsored by Sentry

SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.

Learn More

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.