How to limit iOS keyboard to numeric input
Set the keyboardType
property of the UITextField
to UIKeyboardTypeDecimalPad
.
Swift 3
yourUITextField.keyboardType = .decimalPad
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;