I have set my text field's keyboard to 'Number Pad' in the xcode designer which adds the following code between my tags in my .xib
<textInputTraits key="textInputTraits"
autocorrectionType="no" keyboardType="numberPad"/>
I had expected that when selecting this textfield, the following keyboard input would appear:
But instead, the following input is appearing:
How can i set my text field to use the first input (or similar) instead of the second?
As of Swift 3, it is now a little different. For a UITextField, e.g. height, it'll be like this:
@IBOutlet weak var height: UITextField!
height.keyboardType = UIKeyboardType.numbersAndPunctuation
OR
height.keyboardType = UIKeyboardType.numberPad
Now when you press the text field, proper keyboard will popup.
You can set keyboardType
property of UITextFiled
to UIKeyboardTypePhonePad
as follows:
yourTextField.KeyboardType = UIKeyboardType.NumberPad
Swift 3
In viewDidLoad write -
mobileTextfield.keyboardType = UIKeyboardType.numberPad
you can get more choices in UIKeyboardType
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With