Return to initial view controller when user logs out

Aleksander picture Aleksander · Mar 29, 2014 · Viewed 18.1k times · Source

I'm working on an app which uses Facebook integration, and the log in system works fine now. However, I can't seem to return to my initial view controller when the user clicks log out.

Here's an overview of my storyboard:

Screenshot of storyboard

I would like to return to the start when the user clicks the blue button (on the top). What would I do to achieve that? As you can see I have multiple Navigation Controllers, and I only use Push-seguesto get there. However, I do use the SWRevealViewController, which you can see in the middle.

I've tried [self.navigationController popToRootViewControllerAnimated:YES]; which doesn't do anything.

Any advice? Anyone familiar with the SWRevealViewController and what it might have done to my Navigation stack? Any help will be appreciated!

Thanks.

Answer

Ramdhas picture Ramdhas · Mar 29, 2014

Try this,

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"NameOfYourStoryBoard" 
                                                     bundle:nil];
LoginViewController *add = 
           [storyboard instantiateViewControllerWithIdentifier:@"viewControllerIdentifier"];

[self presentViewController:add 
                   animated:YES 
                 completion:nil];