Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss modal segue

I am trying to understand modal vs push segue and read few Q & A like this and this. One point I am confused from these answers is "The presenter should take care of dismissing the VC it presented."

For example, the example I am writing shows UIPageViewController something like the example available here, with a button at bottom of the page with name "Skip".

In story board I have created a segue (of type Modal) from "Skip" button to another "View Controller" (let us say LoginViewController), but where do I need to dismiss the UIPageViewContoller (if at all required) and how?

EDIT: After little bit more reading, it seems UIPageViewController (Which has Skip button) should take care of dismissing LoginViewController (because UIPageViewController is the presenter).

In my case, after Login complete, I would like to navigate to "Menu" page, then how can I ask UIPageViewController to dismiss the "LoginViewController" and move to MenuController? I couldn't find any example on how this works.Any help would be appreciated!

like image 711
kosa Avatar asked Dec 30 '14 06:12

kosa


1 Answers

As per the tutorial link you have given in question.

There is a APPViewController which is root for the UIPageViewController and also in AppDelegate, so on top of that view, require a Skip button which is above all the subViews in AppViewController. So its IBAction event will be in AppViewController only.

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

Now in its action event of skip button, you can write like this:

[self dismissViewControllerAnimated:YES completion:nil];

So it will automatically dismiss all your AppChildViewControllers, and will display LoginViewController, which is already behind.

This is just a base logic to achieve your goal, you might require to change code as per your project implementation.

Hope this helps.

like image 167
Mrunal Avatar answered Sep 30 '22 18:09

Mrunal