Search code examples
iosobjective-cuipageviewcontroller

How to empty an UIPageViewController (Remove ViewControllers inside)


After setting up a PageViewController I'd like to remove the view controllers inside, leaving it empty.

How can I do this?

I've tried the setViewControllers:direction:animated:completion: method passing nil or an empty array in the viewControllers param but it crashes.

How can I do this?


Solution

  • If calling setViewControllers:direction:animated:completion: with nil for the viewControllers parameter crashes, try setting the view controllers to an array with a single empty view controller.

    [pageViewController setViewControllers:@[UIViewController.new] direction:direction animated:true completion:nil];