Thursday, October 7, 2010

How to Get Rid of Keyboard with a Tap on Background part2

There was a nice way to remove keyboard by using UITextView, but that has stopped working with iOS4. At least I got such a defect report for beta application. This time I will remove keyboard using UIButton, let's see how long that will work:
- (IBAction)removeKeyboard
{
    [textField1 resignFirstResponder];
    [textField2 resignFirstResponder];
}
Open your view in Interface Builder, create new custom full screen UIButton to cover everything, select UITextFields and UIButtons (etc.) one by one and "Send to Front" via Layout menu. Connect UIButton "Touch Up Inside" to your callback and that's it.

Nice, easy, simple, fast - what more can you ask for!

1 comment:

  1. I'm doing exactly that in many of my UIViews with text fields for Ultimate Password Manager...

    ReplyDelete