Search code examples
iosobjective-cuipageviewcontroller

Delete the only one page in UIPageViewController


Whenever I want to refresh my UIPageViewController I call the following snippet, including when I want to delete a viewController from my UIPageViewController.

[self setViewControllers:@[currentViewController] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

Everything is working just fine... except when I want to delete the one and only viewController from my UIPageViewController because I cannot pass an empty array as the first parameter. In fact I get an exception if I do so. How can I force a refresh and not set the current viewController for my UIPageViewController?

Right now I am passing a dummy ViewController but I don't find that very pretty. If I do so I get a page indicator even though I am returning zero in my (NSInteger) presentationCountForPageViewController:(UIPageViewController*)pageViewController overload.


Solution

  • The question makes no sense. There is no such thing as a page view controller without a view controller. If your goal is to hide the page view controller's view, hide it (or even rip the whole thing right out of the interface).