离开文本字段时放弃键盘
嘿,我在两个自定义单元格中创建了一个文本字段。一个文本字段显示标准键盘,另一个文本字段在输入时显示选择器视图。我遇到的问题是,当我从键盘移动到 pickerview 文本字段而不单击键盘上的“返回”按钮时,键盘不会退出。但是,当我使用“返回”键执行此操作时,键盘会失效。正在使用:
- (void)textFieldDidEndEditing:(UITextField *)myTextField{
[myTextField resignFirstResponder];
}
并且无法弄清楚为什么这不起作用。
谢谢, 威廉
Hey, I have created a textfield within two custom cells. One textfield shows the standard keyboard and the other the shows a pickerview when entered. The problem I have is when I move from the keyboard to pickerview textfield without clicking the "return" button on the keyboard, the keyboard doesn't resign. However when I do it using the "return" the keyboard resigns. Am using:
- (void)textFieldDidEndEditing:(UITextField *)myTextField{
[myTextField resignFirstResponder];
}
and can't work out why this isn't working.
Thanks,
William
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的视图控制器是否采用
?它是否连接为您的文本字段的代表?Does your view controller adopt
<UITextFieldDelegate>
? Is it hooked up as the delegate of your text fields?在显示 pickerview 之前尝试使用
[self.view endEditing:YES];
并查看它是否有帮助。Try using
[self.view endEditing:YES];
before showing the pickerview and see it it helps.