未设置transitionViewForCurrentTransition,演示文稿控制器在演示期间被解除

时间:2017-04-01 14:36:16

标签: ios objective-c uiviewcontroller

没有设置TransitionViewForCurrentTransition,演示文稿控制器在演示期间被解雇了? (小于_UIFullscreenPresentationController: 如何解决它,打印没有异常,但在调用上面显示错误

-(IBAction)presume:(id)sender
{
        [self returnToRootViewController];

}



 - (UIViewController*)topmostViewController
    {
        UIViewController* vc = [[[UIApplication sharedApplication] keyWindow] rootViewController];
        while(vc.presentedViewController) {
            vc = vc.presentedViewController;
        }
        return vc;
    }

    - (void)returnToRootViewController
    {
        UIViewController* vc = [self topmostViewController];
        while (vc) {
            if(vc.presentingViewController) {
                if ([vc isKindOfClass:[CarDetailVC class]])
                {

                    @try {



                        [vc dismissViewControllerAnimated:NO completion:^{}];

                    } @catch (NSException *exception) {

                        NSLog(@"exception=%@",exception);
                    } @finally {

                    }


                 }

            }
            vc = vc.presentingViewController;
        }



    }

1 个答案:

答案 0 :(得分:1)

让我们从更直接的目标vc(CarDetailVC实例)开始。

- (UIViewController*)vcWithClass:(Class)klass {
    UIViewController* vc = [[[UIApplication sharedApplication] keyWindow] rootViewController];
    while(![vc.presentedViewController isKindOfClass:klass]) {
        vc = vc.presentedViewController;
    }
    return vc;
}

现在,转到它并解除它所呈现的vc。

- (void)returnToCarVC {
    CarDetailVC *carVC =(CarDetailVC*) [self vcWithClass:[CarDetailVC self]];
    UIViewController *presented = carVC.presentedViewController;
    [presented dismissViewControllerAnimated:NO completion:^{}];
}