BLACK FRIDAY SALE: Save big on all my Swift books and bundles! >>

SOLVED: Number Pad

Forums > watchOS

Does anyone know how to have a number pad show up on a text field using SwiftUI. Maybe it doesn’t even have to be a text field. I just need a way to input numbers for a calculation.

I'm currently using a slider but that's not the most efficient way of doing so.

1      

Hi

On iOS use .keyboardType(.numberPad) but not sure

TextField("Some Number", text: $someText)
      .keyboardType(.numberPad)

PS there are different Keyboards when you put the . in eg .decimalPad pick which one you want to use.

1      

Did you try:

TextField("Something", text: $property).keyboardType(.decimal)

The string is the sample text that will show, it can be empty, and the text prarmeter is the @State property of your choice.

Not sure about watchOS but that's in SwiftUI.

1      

There is no keyboard on watchOS, only the scatch pad. So enless you want to make your number pad like the Calc App or use a picker

1      

Hi everyone, I made my own SwiftUI keypad for WatchOS! Here is the GitHub link. Hope it helps! Demo on 44mm Watch

1      

Hacking with Swift is sponsored by RevenueCat

SPONSORED In-app subscriptions are a pain to implement, hard to test, and full of edge cases. RevenueCat makes it straightforward and reliable so you can get back to building your app. Oh, and it's free if your app makes less than $10k/mo.

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.