简体   繁体   English

UITextField:触发textFieldShouldBeginEditing,但键盘不显示

[英]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. 我通过将以下代码添加到prepareForSegue:方法来解决此问题。 Seems to work. 似乎可以工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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