Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After looking for a lot.</p> <p>I receive that: </p> <pre><code>- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController; - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController; </code></pre> <p>2 functions use to get pageViewController behind or in front of current pageViewController.</p> <p>I thinks it's difficult to get current pageViewController</p> <p>My suggestion:</p> <p>In UIPageViewControllerDelegate, it have a function :</p> <pre><code> - (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers; </code></pre> <p>This function to give you a pendingViewControllers array and this's current pageViewController array. So you can implement like that :</p> <pre><code>- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers { if([pendingViewControllers count]&gt;0) { NSUInteger index =[(APPChildViewController*)[pendingViewControllers objectAtIndex:0] index]; if(index == 0) { self.view.backgroundColor = [UIColor redColor]; } if(index == 1) { self.view.backgroundColor = [UIColor blueColor]; } if(index == 2) { self.view.backgroundColor = [UIColor greenColor]; } } } </code></pre> <p>In viewDidLoad, you add :</p> <pre><code> self.pageController.delegate = self; self.view.backgroundColor = [UIColor redColor]; //set first background. </code></pre> <p>In 'APPViewController.h' you sure add:</p> <pre><code>@interface APPViewController : UIViewController&lt;UIPageViewControllerDataSource,UIPageViewControllerDelegate&gt; </code></pre> <p>Remember : remove this code (in 'viewControllerAtIndex' function)</p> <pre><code>if(index == 1) { self.view.backgroundColor = [UIColor redColor]; } if(index == 2) { self.view.backgroundColor = [UIColor blueColor]; } if(index == 3) { self.view.backgroundColor = [UIColor greenColor]; } </code></pre> <p>Let's me know if you have any questions.</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