Addev
Addev

Reputation: 32233

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?

Upvotes: 4

Views: 3019

Answers (2)

Vasanthan Prem
Vasanthan Prem

Reputation: 195

-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
    return nil;
}

Upvotes: -1

EmilioPelaez
EmilioPelaez

Reputation: 19892

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];

Upvotes: 11

Related Questions