zoukankan      html  css  js  c++  java
  • 获取iOS应用中当前处于Activity状态的ViewController

    转自:http://blog.csdn.net/lixuwen521/article/details/41447507

    // 获取当前处于activity状态的view controller
    - (UIViewController *)activityViewController
    {
        UIViewController* activityViewController = nil;
        
        UIWindow *window = [[UIApplication sharedApplication] keyWindow];
        if(window.windowLevel != UIWindowLevelNormal)
        {
            NSArray *windows = [[UIApplication sharedApplication] windows];
            for(UIWindow *tmpWin in windows)
            {
                if(tmpWin.windowLevel == UIWindowLevelNormal)
                {
                    window = tmpWin;
                    break;
                }
            }
        }
        
        NSArray *viewsArray = [window subviews];
        if([viewsArray count] > 0)
        {
            UIView *frontView = [viewsArray objectAtIndex:0];
            
            id nextResponder = [frontView nextResponder];
            
            if([nextResponder isKindOfClass:[UIViewController class]])
            {
                activityViewController = nextResponder;
            }
            else
            {
                activityViewController = window.rootViewController;
            }
        }
        
        return activityViewController;
    }
  • 相关阅读:
    2021.4.11(每周总结)
    2021.4.9
    2021.4.8
    2021.4.7
    k8s集群安装(一)安装方案介绍
    k8s映射外部服务Endpoints
    Linux服务器配置上网代理squid
    SonarQube学习笔记
    yum安装指定版本mysql
    linux目录没有颜色的处理
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/4380960.html
Copyright © 2011-2022 走看看