how to show numbers in the default keyboard initially for UITextField
In my iPhone application I have an address line 1 field. I have assigned the default keyboard to that. But most likely line 1 field will start with apartment number.
I want 开发者_如何学Goto know how to show numbers in the default keyboard initially for this field.
You may want to use UIKeyboardTypeNumbersAndPunctuation
instead, since the user can then go back to the alphabetical keyboard (by pressing the "ABC" button on the bottom of the keyboard) once the street number is entered. If you use the numberPad, only numbers can be entered.
To do this in IB, open the Inspector and select this as the default keypad. To do this programmatically, just add textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
Try using this........
[textField becomeFirstResponder];
textField.keyboardType = UIKeyboardTypeNumberPad;
Set you textField.inputView as
textField.inputView = nil;
[textField setKeyboardType:UIKeyboardTypeNumberPad];
Follow this tutorial for setting up a 'DONE' button !
http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key
精彩评论