Search code examples
objective-cios8uistoryboardsegue

How to dismiss segue ios8


I am not much familiar with segue. I have used it for very 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 while I am trying to dismiss it on LOGOUT button which is in SideMenu using below method,

 [self dismissViewControllerAnimated:YES completion:nil];

Nothing is happening. Don't know how to dismiss it. Can anyone have solution for this? Thanks in advance!


Solution

  • According the documentation dismissViewControllerAnimated

    Dismisses the view controller that was presented modally by the receiver.

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