iGatiTech
iGatiTech

Reputation: 2268

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!

Upvotes: 3

Views: 596

Answers (2)

Abdul Yasin
Abdul Yasin

Reputation: 3508

[self dismissViewControllerAnimated:YES completion:nil];

Above statement dismisses a view controller when a view controller is present.

If you are using "PUSH" or "SHOW", then your view controller is pushing to navigation stack. Well in that case you have to POP that view controller from the navigation stack.

Try below code

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

Upvotes: 1

Martin
Martin

Reputation: 4765

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.

Upvotes: 1

Related Questions