在UITableViewCell
内加入UIPanGestureRecognizer
时,当在cell
上下滑动tableView
时发现没有响应。可以在
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
locationInView:获取到的是手指点击屏幕实时的坐标点;
translationInView:获取到的是手指移动后,在相对坐标中的偏移量
代理方法内判断滑动方向。如果为上下滑动,返回NO
,否则返回YES
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint transLcation = [pan translationInView:view];
CGFloat absX = fabs(transLcation.x);
CGFloat absY = fabs(transLcation.y);
if (absY > absX) {
return NO;
}
return YES;
}