zoukankan      html  css  js  c++  java
  • iOS开发之获取当前展示的VC

    /** 递归查找当前显示的VC*/

    + (UIViewController *)recursiveFindCurrentShowViewControllerFromViewController:(UIViewController *)fromVC

    {

        if ([fromVC isKindOfClass:[UINavigationController class]]) {

            return [self recursiveFindCurrentShowViewControllerFromViewController:[((UINavigationController *)fromVC) visibleViewController]];

        } else if ([fromVC isKindOfClass:[UITabBarController class]]) {

            return [self recursiveFindCurrentShowViewControllerFromViewController:[((UITabBarController *)fromVC) selectedViewController]];

        } else {

            if (fromVC.presentedViewController) {

                return [self recursiveFindCurrentShowViewControllerFromViewController:fromVC.presentedViewController];

            } else {

                return fromVC;

            }

        }

    }

    /** 查找当前显示的ViewController*/

    + (UIViewController *)getCurrentShowViewController

    {

        UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;

        UIViewController *currentShowVC = [self recursiveFindCurrentShowViewControllerFromViewController:rootVC];

        return currentShowVC;

    }

  • 相关阅读:
    hdu 2003 求绝对值
    hdu 2002 计算球体积
    hdu 2000 ASCII码排序
    hdu 2001 计算两点间的距离
    hdu 2055 An easy problem
    hdu 1000+1089~1096 题解
    hdu 3233 Download Manager
    GIL 全局解释器锁
    多线程,代码示例
    多线程,理论部分
  • 原文地址:https://www.cnblogs.com/hecanlin/p/10752964.html
Copyright © 2011-2022 走看看