iOS 子视图禁止父视图的手势事件

 当主视图添加了  UITapGestureRecognizer  点击方法时,在其上的子视图也会有手势响应,需求点击子视图不响应点击方法

UITapGestureRecognizer 添加代理 

实现代理方法

#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;

}

你可能感兴趣的:(iOS 子视图禁止父视图的手势事件)