Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Taking the PageControl sample from Apple, here's the code that would do this. I tested it and it works fine, except for noticing a jump of the page control when you launch the app from the initial dot to the last one, but I don't know how to solve that. Let me know if this doesn't work for you.</p> <pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application { // view controllers are created lazily // in the meantime, load the array with placeholders which will be replaced on demand NSMutableArray *controllers = [[NSMutableArray alloc] init]; for (unsigned i = 0; i &lt; kNumberOfPages; i++) { [controllers addObject:[NSNull null]]; } self.viewControllers = controllers; [controllers release]; // a page is the width of the scroll view scrollView.pagingEnabled = YES; scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, scrollView.frame.size.height); scrollView.showsHorizontalScrollIndicator = NO; scrollView.showsVerticalScrollIndicator = NO; scrollView.scrollsToTop = NO; scrollView.delegate = self; // First, set the number of pages pageControl.numberOfPages = kNumberOfPages; // Then, tell the page control that you're on the last page (numPages - 1, since we're 0-indexed) pageControl.currentPage = kNumberOfPages - 1; // Now, we have to tell the frame that we're at the end of the frame // So we set the content offset to be the last page scrollView.contentOffset = CGPointMake(scrollView.frame.size.width * (kNumberOfPages - 1), 0); // pages are created on demand // load the visible page // load the page on either side to avoid flashes when the user starts scrolling // [self loadScrollViewWithPage:0]; // [self loadScrollViewWithPage:1]; // Now, instead of loading the original page, we load the last two pages [self loadScrollViewWithPage:kNumberOfPages - 1]; [self loadScrollViewWithPage:kNumberOfPages - 2]; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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