解决触摸事件冲突-UITapGestureRecognizer

首先给你的视图添加触摸点击事件并设置好代理。

@interface LSYMenuView ()<UIGestureRecognizerDelegate>


    [self addGestureRecognizer:({

        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hiddenSelf)];

        tap.delegate = self;

        tap;

    })];


然后在代理中设置需要屏蔽的视图点击手势

#pragma mark -  UIGestureRecognizer Delegate

//解决TabViewTap手势冲突

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

{

    if ([NSStringFromClass([touch.view class]) isEqualToString:@"TopMenuView"]) {

        return NO;

    }

    return  YES;

}


你可能感兴趣的:(解决触摸事件冲突-UITapGestureRecognizer)