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

前端 未结 11 803
清酒与你
清酒与你 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:30

    If you are using Storyboads, use this segue:

    #import "PopToControllerSegue.h"
    
    @implementation PopToControllerSegue
    
    - (void) perform
    {
        UIViewController *sourceViewController = (UIViewController *)self.sourceViewController;
        UIViewController *destinationViewController = (UIViewController *)self.destinationViewController;
    
        for (UIViewController* controller in sourceViewController.navigationController.viewControllers) {
            if ([controller isKindOfClass:destinationViewController.class]) {
                [sourceViewController.navigationController popToViewController:controller animated:YES];
                return;
            }
        }
    
        NSLog(@"PopToControllerSegue has failed!");
    }
    
    @end
    

提交回复
热议问题