The implementation method of scrollView rolling after sliding a segment on the courier flower new feature interface. The new feature scrollview
1. Make scrollView not scroll by user finger
Self. scrollView. scrollEnabled = NO;
2. Add a gesture to scrollView
UIGestureRecognizer * gesture = [[UIPanGestureRecognizeralloc] initWithTarget: selfaction: @ selector (dragView :)];
[Self. scrollViewaddGestureRecognizer: gesture];
3. Process scrollView gestures
# Pragma mark Gesture Recognition callback Method
-(Void) dragView :( UIPanGestureRecognizer *) gesture {
Switch (gesture. state ){
CaseUIGestureRecognizerStateBegan:
_ StartPoint = [gesture translationInView: gesture. view];
Break;
CaseUIGestureRecognizerStateEnded:
CGPoint endPoint = [gesture translationInView: gesture. view];
If (_ startPoint. x-endPoint. x> 40 ){
CGPoint start = self. scrollView. contentOffset;
CGPoint end = CGPointMake (start. x + 100, 0 );
[Self. scrollViewsetContentOffset: end animated: YES];
}
Break;
}
}