How to dismiss segue ios8

I am not very familiar with segue. I used it for the first time.

[self performSegueWithIdentifier:@"LoginSegue" sender:nil];

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    id destinationViewController = segue.destinationViewController;

    if ([destinationViewController isKindOfClass:[MFSideMenuContainerViewController class]])
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:Main bundle:[NSBundle mainBundle]];

        UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:NavigationController];
        MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)destinationViewController;
        UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:LeftSideMenuIdentifier];

        [container setLeftMenuViewController:leftSideMenuViewController];
        [container setCenterViewController:navigationController];


My problem is that I am trying to disable it on the LOGOUT button which is in the SideMenu using the method below,

 [self dismissViewControllerAnimated:YES completion:nil];


Nothing happens. Don't know how to fire him. Does anyone have a solution for this? Thanks in advance!


source to share

2 answers

According to the documentation dismissViewControllerAnimated

Rejects the view controller that was presented modally to the receiver.

So this works for modally exposed controllers, for navigation stacks, use unwind segues instead .



[self dismissViewControllerAnimated:YES completion:nil];


The above statement rejects the view controller when the view controller is present.

If you use "PUSH" or "SHOW" your view controller goes to the navigation stack. In this case, you must POP to view the controller from the navigation stack.

Try to enter the code

[self.navigationController popViewController:yourViewController animated:YES];




All Articles