Friday, 20 July 2018

swift: How to create UIPageViewController?

I want to create UIPageViewController with spine mid location. I read several tutorials with UIPageViewController but in this tutorials used spine min or max location. And I can not create UIPageViewController with spine mid location.
I have this function to create UIPageViewController with spine mid location min or max location:
func createPageViewController() {

            // Instantiate the PageViewController
            let pageController = self.storyboard?.instantiateViewController(withIdentifier: 
"PageViewController") as! UIPageViewController
            pageController.dataSource = self
            pageController.delegate = self

            if images.count > 0{
                let contentController = getContentViewController(withIndex: 0)!
                let contentControllers = [contentController]

                pageController.setViewControllers(contentControllers, direction: 
UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)

            }

            pageViewController = pageController

            self.addChildViewController(pageViewController!)

            self.view.addSubview(pageViewController!.view)
            pageViewController!.didMove(toParentViewController: self)

        }

I tried to change it for this:
let contentController = getContentViewController(withIndex: 0)!
let contentController1 = getContentViewController(withIndex: 1)!
let contentControllers = [contentController, contentController1]

But in this case my images not showing in pages. It is not help. What am I doing wrong? How to create UIPageViewController with spine mid location?


from swift: How to create UIPageViewController?

No comments:

Post a Comment