There is no Done button on a Number Pad-type keyboard. I开发者_如何学C don't want to add a custom Done button, but how do I dismiss the keyboard?
You could add a UINavigationBar/UIToolBar with a done button(a UIBarButtonItem), and make the textField/textView resignFirstResponder on the done button's action.
You can add the UINavigationBar/UIToolBar as inputAccessoryView of textField/textView.
textField.inputAccessoryView = aNavBarWithDoneButton;
Edit: Availability iOS (3.2 and later)
The simplest solution is to add a new button somewhere in your UI that calls resignFirstResponder
on your UITextField
(or whatever) when tapped. Putting this in a toolbar is problematic on iPhone because toolbars are typically at the bottom of the screen and obscured by the keyboard.
A slightly more complex solution is to put an invisible UIView
behind all of your other tappable UI elements. Any taps not handled by your existing UI will go to this new view, which can call resignFirstResponder
on your text field.
If neither of these sound appealing, perhaps you should expand your question to include the type of behavior you want.
精彩评论