美文网首页
iOS开发解决TableView与view手势冲突

iOS开发解决TableView与view手势冲突

作者: 西瓜皮奥特曼 | 来源:发表于2017-09-11 14:56 被阅读445次

    手势代理UIGestureRecognizerDelegate

    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(keyboardHiden)];
    tap.delegate=self;
    [self.view addGestureRecognizer:tap];
    

    #pragma mark- UIGestureRecognizerDelegate

    -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
        if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
            return NO;      //关闭手势
        }
        return YES;
    }
    

    参考链接http://blog.csdn.net/liumude123/article/details/51416555

    相关文章

      网友评论

          本文标题:iOS开发解决TableView与view手势冲突

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