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;

}





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