环境:

       view上添加tableView,给view添加单击手势,点击cell却走的是手势方法.

解决:

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


   #pragma mark-手势代理,解决和tableview点击发生的冲突
   -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
      if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//判断如果点击的是tableView的cell,就把手势给关闭了
         return NO;//关闭手势
      }//否则手势存在
      return YES;
    }
posted on 2017-12-18 19:20  代码少年_夕阳  阅读(2063)  评论(0编辑  收藏  举报