在自定义的uiscroview里添加方法。
左边侧滑:
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{ CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self]; CGPoint location = [gestureRecognizer locationInView:self]; NSLog(@"velocity.x:%f----location.x:%d",velocity.x,(int)location.x%(int)[UIScreen mainScreen].bounds.size.width); 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]; NSLog(@"velocity.x:%f----location.x:%d",velocity.x,(int)location.x%(int)[UIScreen mainScreen].bounds.size.width); if (velocity.x > 0.0f&&(int)location.x%(int)[UIScreen mainScreen].bounds.size.width>[UIScreen mainScreen].bounds.size.width-60) { return NO; } return YES;}