Search code examples
ios6uitextfielduitextfielddelegate

UITextField: textFieldShouldBeginEditing fires, but keyboard does not show


I have a text field that is apparently successfully calling delegate methods as the following method fires when I tap on the test field, but no keyboard shows.

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    NSLog(@"should begin editing");

    return YES;
}

Any ideas as to why?

A couple of details: This text field happens to be in a view controller in a storyboard. The first time I segue to this view the text field works fine. The subsequent times I segue to this view it does not work. I imagine this is a big clue to why I am getting the described behavior, but I have not been able to figure it out yet.


Solution

  • I fixed the issue by adding the code below to the prepareForSegue: method. Seems to work.

    if (_textField.isFirstResponder) {
        [_textTextField resignFirstResponder];
    }