问题
My storyboard is using a UINavigationController
(VC0), I segue using a UIPopover
to load a new UIViewController
(VC1). From this new UIViewController
, I am popping to a new UIViewController
(VC2). When I attempt to close this newest popover, I am being quit back to the UINavigationController
.
The code that I'm using in VC0 to show the VC1 as popover, VC1 to VC2 is the same code (different identifier though):
[self performSegueWithIdentifier:@"titlePopover" sender:self];
The code that I'm using in VC2 to dismiss the popover is:
UIViewController *vc = [self presentingViewController];
[self dismissViewControllerAnimated:YES completion:^{
[[vc presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}];
What it does is dismisses VC2, shows VC1 for a split second, then dismisses VC1 and goes back to the VC0. I want to be able to dismiss VC2 only, so that I'm on VC1
回答1:
If you performing sugue
modally, use code navigate back:
[self dismissViewControllerAnimated:YES completion:nil];
If performing push segue
, use code to navigate back:
[self.navigationController popViewControllerAnimated:YES];
来源:https://stackoverflow.com/questions/42671732/dismissing-a-viewcontroller-shown-as-popover-segue-from-within-another-popover