Is there some way to have a keyboard of type UIKeyboardTypeNamePhonePad start in phone number pad mode rather than alphabetic? The keyboard works well for what I need but I'd like it to start in the "other" mode since that is more likely what the user will enter.
-
Did you happen to get this resolved? If so, what was your solution? – Michael Murray Feb 23 '12 at 16:17
4 Answers
I believe that by setting the keyboardType
property to UIKeyboardTypeNumbersAndPunctuation
, you will default to the numbers and punctuation view, while still having the option of returning to the "ABC" view. Apple's documentation on it: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html
Related question: how to show numbers in the default keyboard initially for UITextField

- 1
- 1

- 982
- 3
- 13
- 29
Unfortunately the answer to this question is NO, but there is a workaround.
You can use the UIKeyboardTypeNumberPad and add a custom button (e.g. https://stackoverflow.com/a/4826342/61569) to switch the keyboard to UIKeyboardTypeNamePhonePad. The challenge with this workaround is to support the keyboard styles of different versions of iOS with this custom button
The UIKeyboardTypeNumberPad does not have the 'Done' or the 'ABC' button that will allow you to toggle back and forth between default keyboard and the NumberPad. Now you can choose to go with what @Anthony F suggested but remember you risk the chance of loosing the custom 'Done' button everytime Apple releases newer versions of iOS and move their keyboard window around. To achieve what you want, your best bet will be to set your keyboardType to UIKeyboardTypeNumbersAndPunctuation. This way, you have your keyboard NumberPad loaded up automatically when your view load and have the 'ABC' button also present to be able to toggle between the default keyboard also if you want.
self.myTextfield.keyboardType = UIKeyboardTypeNumbersAndPunctuation;

- 2,945
- 1
- 15
- 17
In the textfield in question, You set the kind of keyboard you would like it to "activate":
[self.myTextfield setKeyboardType:UIKeyboardTypeNumberPad];

- 11,380
- 13
- 81
- 120
-
Thanks RickiG but that doesn't quite get me where I need to go. The numberpad just has numbers. I need both numbers and letters but want it to default to numbers since that is likely what the user will need most. Good example would be something like apartment numbers that are typically just numbers but sometimes need a letter extension (e.g. 205A). – CBGrey Mar 22 '10 at 20:28