iphone - 如何在 uitableviewcell 中将文本字段辞去第一响应者

标签 iphone objective-c cocoa-touch uitableview uitextfield

在使用标准 UIView 时,我使用此代码将我的 UITextField 辞职为 firstResponder

但我现在在 UITableViewUITableViewCell 中有 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];
}

enter image description here

最佳答案

[[self tableView] endEditing:YES]; 是我的标准方法。

关于iphone - 如何在 uitableviewcell 中将文本字段辞去第一响应者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8248477/

相关文章:

iphone - 针对不同国家/地区的游戏本地化

objective-c - 如何在 Objective-C 类中初始化常量成员 C 数组?

iPhone 应用程序 : How to implement horizontal knob as shown in image

iphone - 如何将坐标从英寸转换为像素?

Swift:检查 UISearchBar.text 是否包含 url

iphone - 自定义键盘 iphone,UITextView 中的退格按钮有问题

iphone - 应用设计

ios - 在右侧显示详细 VC 之前,如何从主 VC 推送到左侧的第二个 VC?

ios - 在 UIViewController 上动态创建 UIWebView

ios - NSCoding 在 Swift 的继承类中需要初始值设定项