在使用标准 UIView
时,我使用此代码将我的 UITextField
辞职为 firstResponder
。
但我现在在 UITableView
的 UITableViewCell
中有 UITextField
,当我单击时,代码不会将文本字段作为第一响应者在文本字段之外。任何想法如何使这项工作?
- (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];
是我的标准方法。
关于iphone - 如何在 uitableviewcell 中将文本字段辞去第一响应者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8248477/