iOS UIScrollview 和侧滑手势冲突解决方法

xiaoxiao2021-02-28  86

在自定义的uiscroview里添加方法。

左边侧滑: - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {     CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self];     CGPoint location = [gestureRecognizer locationInView:self];          if (velocity.x > 0.0f&&(int)location.x%(int)[UIScreen mainScreen].bounds.size.width<60) {         return NO;     }     return YES; }

右边侧滑: - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {     CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self];     CGPoint location = [gestureRecognizer locationInView:self];          if (velocity.x > 0.0f&&(int)location.x%(int)[UIScreen mainScreen].bounds.size.width>[UIScreen mainScreen].bounds.size.width-60) {         return NO;     }     return YES; }
转载请注明原文地址: https://www.6miu.com/read-60829.html

最新回复(0)