UIPanGestureRecognizer和UIScrollView冲突了 怎么破
1个回答
展开全部
把下面这段加进去
//解决cell手势和uitableview下滑的冲突
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
// Find the current vertical scrolling velocity
CGFloat velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:gestureRecognizer.view].y;
// Return YES if no scrolling up
return fabs(velocity) <= 0.2;
}
return YES;
}
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]])
{
CGPoint translation = [gestureRecognizer translationInView:self.superview];
return fabs(translation.y) <= fabs(translation.x);
}
return YES;
}
//解决cell手势和uitableview下滑的冲突
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
// Find the current vertical scrolling velocity
CGFloat velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:gestureRecognizer.view].y;
// Return YES if no scrolling up
return fabs(velocity) <= 0.2;
}
return YES;
}
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]])
{
CGPoint translation = [gestureRecognizer translationInView:self.superview];
return fabs(translation.y) <= fabs(translation.x);
}
return YES;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询