当主视图添加了 UITapGestureRecognizer 点击方法时,在其上的子视图也会有手势响应,需求点击子视图不响应点击方法
UITapGestureRecognizer 添加代理 <UIGestureRecognizerDelegate>
实现代理方法
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {
UITapGestureRecognizer *tap = (UITapGestureRecognizer *)gestureRecognizer;
CGPoint point = [tap locationInView:self];
BOOL isIn = CGRectContainsPoint(self.whiteView.frame,point);
return !isIn;
}