简体   繁体   中英

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM