如何在iitableviewcell中将textfield作为第一响应者 [英] How to resign textfield as first responder in uitableviewcell
本文介绍了如何在iitableviewcell中将textfield作为第一响应者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当使用标准 UIView时,我使用此代码将
。 UITextField
辞职为 firstResponder
I use this code to resign my UITextField
as firstResponder
when using a standard UIView
.
但我现在在我的 UITableViewCell中有
在 UITextField
UITableView
中,当我在textField外部单击时,代码不会将文本字段作为第一响应者重新签名。任何想法如何使这个工作?
But I now have UITextField
in my UITableViewCell
in a UITableView
, and the code does not resign the textfield as first responder when I click outside of the textField. Any ideas how to make this work?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if ([self.temperatureTextField isFirstResponder] && [touch view] != self.temperatureTextField) {
[self.temperatureTextField resignFirstResponder];
}
[super touchesBegan:touches withEvent:event];
}
推荐答案
[[self tableView] endEditing:YES];
是我的标准方法。
这篇关于如何在iitableviewcell中将textfield作为第一响应者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文