ios 视图间相互跳转

一、模态视图控制器:

A—> B —> C —> D —> A(或B);

[A presentViewController:B animated:true completion:nil];

[B presentViewController:C animated:true completion:nil];

[C presentViewController:D animated:true completion:nil];

从D控制器回到A(或者B)控制器:

 UIViewController * tempvc = D.presentingViewController;

    while (tempvc) {

        if([tempvc isKindOfClass:[A class]]){

            [tempvc dismissViewControllerAnimated:true completion:nil];

        }

        tempvc = tempvc.presentingViewController;

    }

二、导航视图控制器

[A.navigationController pushViewController:B animated:true];

[B.navigationController pushViewController:C animated:true];

[C.navigationController pushViewController:D animated:true];

从D控制器回到A控制器:

[D.navigationController popToRootViewControllerAnimated:true];

从D控制器回到B控制器:

    for (UIViewController * tempvc in D.navigationController.viewControllers ) {

        if([tempvc isKindOfClass:[B class]]){

            [D.navigationController popToViewController:tempvc animated:true];

        }

    }

三、模态视图和导航视图混合跳转:

结合一二方法即可,但是需注意内存释放问题。

你可能感兴趣的:(Swift,Objectvie_C)