Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should disable paging and add a <a href="https://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIPanGestureRecognizer_Class/Reference/Reference.html" rel="noreferrer">UIPanGestureRecognizer</a> to your scroll view and handle the paging yourself.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; CGRect viewRect = self.view.bounds; // View controller's view bounds theScrollView = [[UIScrollView alloc] initWithFrame:viewRect]; theScrollView.scrollsToTop = NO; theScrollView.pagingEnabled = NO; theScrollView.delaysContentTouches = NO; theScrollView.delegate = self; [self.view addSubview:theScrollView]; UIPanGestureRecognizer * peter = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)] autorelease]; [theScrollView addGestureRecognizer:peter]; } -(void)handlePan:(UIPanGestureRecognizer*)recognizer{ switch (recognizer.state) { case UIGestureRecognizerStateBegan:{ // panStart and startPoint are instance vars for the viewContainer panStart = theScrollView.contentOffset; startPoint = [recognizer locationInView:theScrollView]; break; } case UIGestureRecognizerStateChanged:{ CGPoint newPoint = [recognizer locationInView:theScrollView]; CGFloat delta = startPoint.x - newPoint.x; if ( abs(delta) &gt; 2) theScrollView.contentOffset = CGPointMake( theScrollView.contentOffset.x + delta, 0); CGFloat moveDelta = panStart.x - theScrollView.contentOffset.x; // current witdh should hold the currently displayed page/view in theScrollView if ( abs(moveDelta) &gt; (currentWidth * 0.40)){ panStart = theScrollView.contentOffset; startPoint = newPoint; //NSLog(@"delta is bigger"); if ( moveDelta &lt; 0 ) [self incrementPageNumber]; // you should implement this method and present the next view else [self decrementPageNumber]; // you should implement this method and present the previous view recognizer.enabled = NO; // disable further event until view change finish } break; } case UIGestureRecognizerStateEnded: case UIGestureRecognizerStateCancelled: recognizer.enabled = YES; [self showDocumentPage:currentPage]; break; default: break; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload