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

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.

6      

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.

5      

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.

5      

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

5      

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

5      

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!

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.