Reject modal segue

I am trying to understand modal vs push segue and read some Q and A like this and this . One point that I am confused about from these answers is, “The host must take care to reject the submitted VC.”

For example, the example I'm writing shows the UIPageViewController something like the example available here , with a button at the bottom of the page named Skip.

In the bulletin board, I created a segue (of type Modal) from the Skip button to another “View Controller” (say LoginViewController), but where do I need to reject the UIPageViewContoller (if at all) and how?

EDIT: After a bit more reading, it looks like the UIPageViewController (which has the Skip button) should take care to reject the LoginViewController (since the UIPageViewController is leading).

In my case, after completing the login, I would like to go to the "Menu" page, and then how can I ask the UIPageViewController to reject "LoginViewController" and go to MenuController? I could not find any example of how this works. Any help would be appreciated!

+5
source share
2 answers

In accordance with the link to the tutorial that you asked.

There is an APPViewController , which is the root of the UIPageViewController , as well as in AppDelegate , so the Skip button is required at the top of this view, which is above all the subspecies in APPViewController . Thus, its IBAction event will only be in the APPViewController .

Now first change AppDelegate self.window.rootViewController to LoginViewController . In the LoginViewController event LoginViewController viewDidLoad presentModal UIPageViewController .

Now in your event the action of the skip button you can write like this:

 [self dismissViewControllerAnimated:YES completion:nil]; 

Thus, it will automatically turn off all your AppChildViewControllers and display the LoginViewController , which is already behind.

This is just the basic logic to achieve your goal, you may need to change the code in accordance with the implementation of your project.

Hope this helps.

+5
source

First let go of the UIPageViewController and then use the delegate or block methods (whatever suits you) to get notified when you click the skip button in the parent controller and then call LoginViewController.

0
source

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


All Articles