Keyboard Type For UITextView

user1437241 picture user1437241 · Jul 19, 2012 · Viewed 8.4k times · Source

I would like to know how to obtain the keyboard type of a uitextview. I was able to obtain the keyboard type for a uitextfield by using textfield.keyboardtype but it doesnt seem to work for a uitextview. Kindly help me through this.

Thanks in advance.

Answer

iOS Test picture iOS Test · Jul 19, 2012

try this

UITextView *txvw = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 24, 20)];
txvw.keyboardType =UIKeyboardTypeURL;

and alternate keyboard types are

UIKeyboardTypeDefault,                // Default type for the current input method.
UIKeyboardTypeASCIICapable,           // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
UIKeyboardTypeNumbersAndPunctuation,  // Numbers and assorted punctuation.
UIKeyboardTypeURL,                    // A type optimized for URL entry (shows . / .com prominently).
UIKeyboardTypeNumberPad,              // A number pad (0-9). Suitable for PIN entry.
UIKeyboardTypePhonePad,               // A phone pad (1-9, *, 0, #, with letters under the numbers).
UIKeyboardTypeNamePhonePad,           // A type optimized for entering a person's name or phone number.
UIKeyboardTypeEmailAddress,           // A type optimized for multiple email address entry (shows space @ . prominently).