How to reject a UIPageViewController?

I added a UIPageViewController for instructions in my new game, and I want to reject the UIPageViewController after the user clicks the β€œGOT IT” button on the last UIViewController that connects to the UIPageViewController

I have tried this so far:

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

And it does not remove the UIPageViewController , why?

And how can I let him go?

To show / present a UIPageViewController , I do this:

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

10 times in advance!

+6
source share
4 answers

Please try the callbacks you described:

 [self.pageVC.view removeFromSuperview]; [self.pageVC removeFromParentViewController]; 
+8
source

I had a problem with the solution that I found here and in other posts because I called dismissViewController in one of the views of the pageViewController children, so I did not reject the pageViewController itself, as shown in the shown children.

Turns out I found a quick way to dismiss the pageViewController from one of my sub-objects by pressing a button: just connect this button to the "Exit" button in the storyboard to relax (and provide the unwind method in the vc clause).

0
source

If you want to remove the UIPageViewController from one button on one of the pages, you can add the code below to the button action. This is similar to the answer given by Alex Peda, the difference in the link to pageViewController is through the parentViewController property.

let pvc = self.parentViewController like! UIPageViewController

// delete the contents of the contents of the page controller from the supervisor.
pvc.view.removeFromSuperview ()

// remove the viewview control from the parent view controller. pvc.removeFromParentViewController ()

0
source

Swift 4 / Xcode 9:

Although all the suggested answers did not work for me, this simple line worked:

 navigationController?.popViewController(animated: true) 
0
source

Source: https://habr.com/ru/post/972527/


All Articles