Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The home screen is just an <code>UIScrollView</code> with <code>UIPageControl</code> It's that easy :)</p> <p>Example :</p> <pre><code>// MyViewController.h @interface MyViewController : UIViewController &lt;UIScrollViewDelegate&gt; { UIScrollView *_scrollView; UIPageControl *_pageControl; } // MyViewController.m // in your viewDidLoad method int numberOfPages = 3; _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; [_scrollView setContentSize:CGSizeMake(numberOfPages*_scrollView.frame.size.width, _scrollView.frame.size.height)]; [_scrollView setPagingEnabled:YES]; [_scrollView setShowsHorizontalScrollIndicator:NO]; [_scrollView setDelegate:self]; [self.view addSubview:_scrollView]; _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, _scrollView.frame.size.height-30, _scrollView.frame.size.width, 20)]; [_pageControl setNumberOfPages:numberOfPages]; [_pageControl setCurrentPage:0]; [self.view addSubview:_pageControl]; for (int i=0; i&lt;numberOfPages; i++) { CGRect frame = _scrollView.frame; frame.origin.x = frame.size.width * i; frame.origin.y = 0; UIView *view = [UIView alloc] initWithFrame:frame]; //Setup your view [_scrollView addSubview:view]; } </code></pre> <p>If you want to execute specific method regarding current view displayed, use the <code>scrollViewDidScroll:</code> method (for example to load content from database)</p> <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)sender { CGFloat pageWidth = _scrollView.frame.size.width; int page = floor((_scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; _pageControl.currentPage = page; //do whatever you want.. } </code></pre> <p>It's just an example to show you how you could do. If you're using database or if each view is different you should proceed differently to setup your views or retrieve data but the logic would be the same...</p>
    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.
    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