Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 to know how to show numbers in the default keyboard initially for this field.

like image 233
Janaka Avatar asked Jun 04 '11 04:06

Janaka


3 Answers

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;

like image 112
PengOne Avatar answered Nov 14 '22 02:11

PengOne


Try using this........

 [textField becomeFirstResponder];
 textField.keyboardType = UIKeyboardTypeNumberPad;
like image 36
Mehul Mistri Avatar answered Nov 14 '22 03:11

Mehul Mistri


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

like image 1
Legolas Avatar answered Nov 14 '22 04:11

Legolas