美文网首页
子视图不响应父类手势

子视图不响应父类手势

作者: 西西西瓜sama | 来源:发表于2016-12-08 16:46 被阅读37次

开发中经常会遇到子视图不响应父类手势的问题,解决方法:

- (void)cancelAction {
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hidden)];
    tap.delegate = self;
    [self addGestureRecognizer:tap];
    
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    
    if ([touch.view isDescendantOfView:self.tableView]) {
        return NO;
    }
    
    return YES;
    
}

相关文章

网友评论

      本文标题:子视图不响应父类手势

      本文链接:https://www.haomeiwen.com/subject/onesmttx.html