ios: how to dismiss a modal view controller and then pop a pushed view controller

前端 未结 1 593
忘了有多久
忘了有多久 2021-02-19 21:48

I have a view controller B that is pushed onto the navigation stack by root view controller A and this view controller B needs to display an alternative view if its model is in

相关标签:
1条回答
  • 2021-02-19 22:12

    In the scenario you posted, the presenting view controller for view controller C will actually be the navigation controller, so you can ask it to pop off B, and then dismiss yourself. This code is in view controller C:

    -(IBAction)goBackToA:(id)sender {
        [(UINavigationController *)self.presentingViewController  popViewControllerAnimated:NO];
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    

    If you are using a storyboard, you can do this same thing, jumping directly back to A with an unwind segue.

    0 讨论(0)
提交回复
热议问题