zoukankan      html  css  js  c++  java
  • IOS开发~灵活使用 dismissViewControllerAnimated / dismissModalViewControllerAnimated

    当遇到:

     A presentViewController B ,  B presentViewController C,  C presentViewController D,问如何从D一下子回到A,麻烦一点的办法就是一级一级的dismiss。

    下面来说说我的办法:

    首先,实现 BaseViewController 作为所有视图控制器的基类,然后在基类中实现返回最下层viewController的办法(注意:最底层是UIViewController,所有BaseViewController都放在其上边!):

    - (void) turnToGame

    {

    UIViewController *viewController = self;

        while (viewController.presentingViewController)

        {

            if ([viewController isMemberOfClass:[BaseViewController class]])  // 直到找到最底层为止

            {

                viewController = viewController.presentingViewController;

            }

            else

            {

                break;

            }

        }

        

        if([[[UIDevicecurrentDevice]systemVersion]floatValue] >=6)

        {

            if (viewController)

            {

                [viewController dismissViewControllerAnimated:YEScompletion:nil];

            }

        }

        else

        {

            if (viewController)

            {

                [viewController dismissModalViewControllerAnimated:YES];

            }

        }

     

    本段代码仅仅说明了实现的思想,具体的实现根据项目需求而定。

  • 相关阅读:
    redhat 7.6 常用命令
    redhat 7.6 VI编辑操作
    redhat 7.6 网络配置
    华为学习配置笔记-01 配置con密码
    redhat 7.6 ssh 服务配置
    web前端面试第一次[addEventListenr();绑定事件]
    redis集群搭建
    linux服务器重启后redis数据丢失问题
    redis日志文件路径的设置
    linux下redis安装使用
  • 原文地址:https://www.cnblogs.com/yingkong1987/p/3343937.html
Copyright © 2011-2022 走看看