如果点击事件截取,通过代理继续响应者链

来源:互联网 发布:js省市区三级联动 编辑:程序博客网 时间:2024/05/17 15:41
    self.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];

    self.tap.delegate = self;
    [self.contentViewController.view addGestureRecognizer:self.tap];
}

- (void) tapAction:(UITapGestureRecognizer *)tap
{
    //

    // 这里截断了点击事件

    //
        CGPoint point = [tap locationInView:self.view];
        if (CGRectContainsPoint(CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height), point)) { //判断点击的点是否在中间视图上
            [self showLeft:NO];

        }



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

    CGPoint point = [touch locationInView:self.view];
    NSLog(@"===%f",point.y);

    if (point.y > [UIScreen mainScreen].bounds.size.height - 64 - 49)
    {
        //放过button点击拦截
        return NO;
    }else{
        [touch locationInView:self.contentViewController.view];
        return YES;
    }

}
0 0
原创粉丝点击