Sonic Master Sonic Master - 1 month ago 11
Swift Question

Add UIPageControl to UIPageViewController via storyboard

I try to create onboarding page by following this tutorial and it works great.

That link suggest to create every page onboarding as single view controller using storyboard, then wrap it on my class which is subclass of

UIPageViewController
.

By following that tutorial, I already created nice onboarding page but there is one question remaining. Basically, I created each page of my onboarding pages using storyboard and create its class subclassing
UIViewController
. Then I dragged
UIPageViewController
which is my initial view controller. The result is created onboarding page that has black dot indicator on bottom page. I try to move that indicator and modify it, but still has no clue.

So my first step is remove implementation of its datasource method
presentationCountForPageViewController
and
presentationIndexForPageViewController
, my indicator has disappear.

My question is, where should I add
UIPageControl
so my onboarding page doesn't use its bottom indicator?

Any help would be appreciated. Thank you!

Answer

Subclass UIPageViewController is not the best idea. Better is to create a container view controller for UIPageViewController that will conform to UIPageViewControllerDataSource and UIPageViewControllerDelegate. Using storyboard you can add to you container view controller's view a container view that load your UIPageViewController. Get your UIPageViewController from -prepareForSegue:sender: method to configure. Now you're able to manage your UIPageViewController from container view controller. Good luck!

Comments