我有两件事相互碰撞。每个单独工作都很好。但我不知道如何让它们同时工作。事情是这样的,我有一些文本字段和按钮,当用户触摸背景时,我添加了关闭键盘,但是这个方法也会被调用,然后用户尝试点击按钮。所以按钮不再起作用。这是我的键盘关闭的一些代码,也许有人会知道如何正确实现它。
-(void)dismissKeyboard {
NSLog(@"resign");
[[_textFields objectAtIndex:0] resignFirstResponder];
[[_textFields objectAtIndex:1] resignFirstResponder];
[[_textFields objectAtIndex:2] resignFirstResponder];
[[_textFields objectAtIndex:3] resignFirstResponder];
}
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissKeyboard)];
[TableControll.view addGestureRecognizer:tap];
[TableControll.view addSubview:save];
[button addTarget:self action:@selector(goAdvanced)
forControlEvents:UIControlEventTouchUpInside];
[save addTarget:self action:@selector(saveInfo)
forControlEvents:UIControlEventTouchUpInside];