Dismissing a ViewController shown as Popover segue from within another Popover

雨燕双飞 提交于 2019-12-12 03:58:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!