'Tried to pop to a view controller that doesn't exist.'

前端 未结 11 788
清酒与你
清酒与你 2021-02-05 12:13

I am getting this error when I call my method dismissView. Here is the method stub:

-(IBAction)dismissView
{
    RootViewController *rootController = [[RootViewC         


        
11条回答
  •  野性不改
    2021-02-05 12:53

    Swift 4

    For anyone still looking for a better solution that doesn't involve the UINavigationController stack indexes, which is getting more problematic with bigger navigation stack - here's the easiest way to solve this:

    if let destinationViewController = navigationController?.viewControllers
                                                            .filter(
                                          {$0 is DestinationViewController})
                                                            .first {
        navigationController?.popToViewController(destinationViewController, animated: true)
    }
    

提交回复
热议问题