辞职第一响应者仅在一个文本字段中不起作用
希望有人能在这里帮助我。我有一个带有 3 个文本字段的 UIView。我希望键盘上的“返回”键让第一个响应者辞职,无论用户光标位于哪个文本字段中。我的代码适用于 3 个文本字段中的 2 个,但始终(一如既往)它拒绝首先辞职来自第三个文本字段的响应者,我不知道为什么(文本字段是相同的。不起作用的字段是第三个字段...
这是代码(如果有帮助的话)
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[firstTextField resignFirstResponder];
[secondTextField resignFirstResponder];
[thirdTextField resignFirstResponder];
return YES;
}
中的属性声明
@property (weak, nonatomic) IBOutlet UITextField *firstTimeTextField;
@property (weak, nonatomic) IBOutlet UITextField *secondTextField;
@property (weak, nonatomic) IBOutlet UITextField *thirdTextField;
这是 H It 看起来很简单,所以我想知道是否应该进行某种错误检查来确定这里发生的情况。
该文件也被声明为 UITextFieldDelegate...
感谢您的时间和帮助!
Hopefully somebody can help me out here. I have a UIView with 3 text fields. I want the "return" key from the keyboard to resign the first responder, regardless of which text field the users curser is in. My code works for 2 of the 3 text fields, but consistently (as in always) it refuses to resign first responder from the 3rd text field, and I don't know why (the text fields are identical. The field that does not work is the 3rd field...
Here is the code if it helps
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[firstTextField resignFirstResponder];
[secondTextField resignFirstResponder];
[thirdTextField resignFirstResponder];
return YES;
}
Here is the property declaration in the H
@property (weak, nonatomic) IBOutlet UITextField *firstTimeTextField;
@property (weak, nonatomic) IBOutlet UITextField *secondTextField;
@property (weak, nonatomic) IBOutlet UITextField *thirdTextField;
It seems pretty straight forward, so I'm wondering if there is some kind of error checking that I should be doing to determine whats happening here.
The file is declared as a UITextFieldDelegate as well...
Thanks for the time and the assistance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将委托设置为所有 UITextFields?
将委托设置为所有 UITextField。
Have you set the delegate to ALL UITextFields?
Set the delegate to all UITextFields.