Tuesday, May 17, 2011

Kill all firstResponder

If you ever have the problem of keyboard not resigning, it is most probably caused by "runaway" pointer to the texfield/textview that was holding the firstresponder. The popular way to clear all firstResponder in the view is by iterating through all the views and check if it's firstResponder -- and if it is, then resign.

- (void)resetKeyboard {
    // Resign keyboard
    for (UIView *view in [self.view subviews]) {
        if ([view isFirstResponder]) {
            [view resignFirstResponder];

No comments: