Reputation: 36643
The question pretty much says it all. Is there any way to have the iOS/iPhone keyboard default to numeric input?
Upvotes: 31
Views: 28605
Reputation: 541
Objective-C:
Default to Numbers (but include - and . if you need to allow decimal or negative numbers):
myTextField1.keyboardType=UIKeyboardTypeNumbersAndPunctuation;
Default to Numbers (#s only for integer values)
myTextField1.keyboardType=UIKeyboardTypeNumberPad;
Upvotes: 2
Reputation: 8309
Set the keyboardType
property of the UITextField
to UIKeyboardTypeDecimalPad
.
yourUITextField.keyboardType = .decimalPad
Upvotes: 60