Manipulating the keyboard

902 views Asked by At

So, I'd like to change the layout of the keyboard inside my app, such that it will include a next button(which would switch between text fields, similar to the tab key on a normal keyboard) and done button (to dismiss the keyboard altogether).Another thing I'd like to change would be to make the keyboard bring up the numpad instead of the usual layout when you choose certain text fields (which are meant to accept numbers only). However, I don't have a clue how to do such a thing. Any assistance would be greatly appreciated.

1

There are 1 answers

0
mackworth On BEST ANSWER

Sorry, other than choosing between Apple's different system keyboards, if you want both Next and Done, you'd have to write the whole thing yourself...

So you have a choice between the Done button and the Next button. These just rename the Return key to Done or Next; hence you can't have both Next and Done at the same time.

You get the Next button by setting

textField.returnKeyType = UIReturnKeyNext

When you get the return key msg, you can then call setFirstResponder on the next text field for your user. Presumably on the last field, you get the Done button by setting

textField.returnKeyType = UIReturnKeyDone

For the number keypad you can set your

 textField.keyboardType = UIKeyboardTypeNumberPad

Your choices for keyboard types are:

   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeDecimalPad

Note that these are all localized for you.