美文网首页iOS开发系列面试uicllectionView
UITapGestureRecognizer与didSelect

UITapGestureRecognizer与didSelect

作者: 旺仔爸 | 来源:发表于2016-02-25 09:58 被阅读428次

    需求要做一个这样的下拉弹窗 点击弹窗选中Cell 点击其他区域弹窗消失

    111.png

    贴代码

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onTapDissMissSelf)];
          
          
          self.userInteractionEnabled = YES;
          
          tap.delegate = self;
          
          
          [self addGestureRecognizer:tap];
    
    

    解决冲突代码 这个是UIGestureRecognizerDelegate 代理方法

    -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
    {
        if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//如果当前是tableView
            //做自己想做的事
            return NO;
        }
        return YES;
    }
    
    

    相关文章

      网友评论

      本文标题:UITapGestureRecognizer与didSelect

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