How to put the UIPageControl element on top of the sliding pages within a UIPageViewController?

后端 未结 7 1769
闹比i
闹比i 2020-12-02 10:20

Regarding to this tutorial by AppCoda about how to implement a app with UIPageViewController I\'d like to use a custom page control element on top of the pages instead of at

7条回答
  •  死守一世寂寞
    2020-12-02 11:04

    sn3ek Your answer got me most of the way there. I didn't set the current page using the viewControllerCreation methods though.

    I made my ViewController also the delegate of the UIPageViewController. Then I set the PageControl's CurrentPage in that method. Using the pageIndex maintained I'm the ContentViewController mention in the original article.

    - (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed
    {
      APPChildViewController *currentViewController = pageViewController.viewControllers[0];
      [self.pageControl setCurrentPage:currentViewController.pageIndex];
    }
    

    don't forget to add this to viewDidLoad

    self.pageViewController.delegate = self;
    

    To follow up on PropellerHead's comment the interface for the ViewController will have the form

    @interface ViewController : UIViewController 
    

提交回复
热议问题