I have customized UIAlertView a bit. My implementation inherits from UIAlertView and adds a textfield to it. If the textfield is tapped, the iPad’s keyboard shows up.
Would I would like to achieve in additon however:
- If the user presses “OKAY” in the alert view, the keyboard does not go away. How can I realize that?
- The on the keyboard “RETURN” is pressed, I would like to dismiss the alert view (and of course hide the keyboard). Also here: how the heck..?
The code of my custom alert view can be seen here: http://www.wildsau.net/post/2011/01/28/iOS-UIAlertView-with-a-UITextField-a-MonoTouch-implementation.aspx
Note that it is MonoTouch but any solution working for ObjC, I will be able to translate.
To dismiss the keyboard when the user taps the alert’s OK button, in the appropriate alert delegate method
do this:
To dismiss your alert view programmatically, use this:
Then you use the same code in clickedButtonAtIndex: to resignFirstResponder to cancel the keyboard.