Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios TextField resignFirstResponder不工作_Ios_Objective C_Uitextfield - Fatal编程技术网

Ios TextField resignFirstResponder不工作

Ios TextField resignFirstResponder不工作,ios,objective-c,uitextfield,Ios,Objective C,Uitextfield,我已经创建了5个文本字段 并且,在tableView中创建tap以隐藏textfield的键盘 UITapGestureRecognizer *tapTableView = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapTable)]; [_tableView addGestureRecognizer:tapTableView]; -(void)tapTable{ [txt1 res

我已经创建了5个文本字段

并且,在tableView中创建tap以隐藏textfield的键盘

UITapGestureRecognizer *tapTableView = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapTable)];
    [_tableView addGestureRecognizer:tapTableView];

-(void)tapTable{
    [txt1 resignFirstResponder];
    [txt2 resignFirstResponder];
    [txt3 resignFirstResponder];
    [txt4 resignFirstResponder];
    [txt5 resignFirstResponder];
}
但是,它不是隐藏键盘,它被称为tapTable,但不是隐藏键盘


我怎样才能解决这个问题

这是因为您没有设置IBOutlet并编写更多preety代码,如下所示。不需要放弃每个文本字段

-(void)tapTable{
      [self.view endEditing:YES];
}
你不需要那样做。 只用

[self.view endEditing:YES];

是否已检查IBOutlet是否正确给定?TableView是否具有IBOutlet@property(弱、非原子)IBOutlet UITableView*TableView;