tableViewCell單擊和View衝突

_lowView 添加了單擊手勢

[self.view addSubview:_lowView];


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

   [_lowView addGestureRecognizer:tap];


[_lowView addSubView:table];


造成的結果: table單擊cell,正常單擊無反應,需要長按幾秒才返回正常值。

解決方法:

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

        tap.delegate = self;

        [_lowView addGestureRecognizer:tap];

        

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

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

        return NO;

    }

    return YES;

}





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章