iosuiviewcontrolleruipageviewcontroller

How to dismiss UIPageViewController?


I added a UIPageViewController for instructions in my new game, and I want to dismiss the UIPageViewController after the user pressed the "GOT IT" button on the last UIViewController that connect to the UIPageViewController

I've tried this so far:

[self.pageVC dismissViewControllerAnimated:YES completion:nil];

And it doesn't remove the UIPageViewController, Why that?

And how can I dismiss it?

In order to show/present the UIPageViewController I do this:

[self addChildViewController:self.pageVC];
[self.view addSubview:self.pageVC.view];
[self.pageVC didMoveToParentViewController:self];

Solution

  • Please try the opposite calls you have described:

    [self.pageVC.view removeFromSuperview];
    [self.pageVC removeFromParentViewController];