一:在同一个view上加载,UITapGestureRecognizer手势,UIButton 行为,UITabelView点击事件冲突;
二:解决方式:
在UITapGesttureRecognizer的手势的代理
UIGestureRecognizerDelegate
里面屏蔽上面的冲突事件
三:如代码:
//处理键盘取消 UITapGestureRecognizer *resinTheInput = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(resignTheInPuts)]; resinTheInput.cancelsTouchesInView = NO; resinTheInput.delegate = self; [self.view addGestureRecognizer:resinTheInput];
代理:
#pragma mark - UIGestureRecognizer delegate//UITapGestureRecognizer代理--影响视图上某些控件的action事件- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ if ([touch.view isKindOfClass:[UIButton class]]) { return NO; }else if ([touch.view isKindOfClass:[UITableView class]]) { return NO; } return YES;}
参考: