其他分享
首页 > 其他分享> > Appdelegate 获取当前控制器 针对某个控制器单独处理

Appdelegate 获取当前控制器 针对某个控制器单独处理

作者:互联网

        UITabBarController *classNameVC =(UITabBarController *) [self getCurrentVC];
        NSLog(@"++++++++%@",classNameVC);
        UINavigationController *selectVC =classNameVC.selectedViewController;
        if ([selectVC.topViewController isKindOfClass:[LMSNewPKWebVC class]]) {
            
        }
        else
        {
            [self.window.rootViewController dismissViewControllerAnimated:NO completion:nil];
            self.tabbarController.delegate= self;
            [self.tabbarController setSelectedIndex:1];
            UINavigationController *appNavC = self.tabbarController.viewControllers[1];
            LMSNewPKWebVC *vc = [[LMSNewPKWebVC alloc] init];
            vc.typeStr = @"4";
            vc.urlStr = H5ActivityThroughMap;;
            [appNavC pushViewController:vc animated:YES];
        }

 

 

- (UIViewController *)getCurrentVC
{
        UIViewController *result = 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;
                                        }
                            }
                }
           
        UIView *frontView = [[window subviews] objectAtIndex:0];
        id nextResponder = [frontView nextResponder];
           
        if ([nextResponder isKindOfClass:[UIViewController class]])
                result = nextResponder;
        else
                result = window.rootViewController;
           
        return result;
}

标签:控制器,vc,self,nextResponder,Appdelegate,tabbarController,window,result,某个
来源: https://blog.csdn.net/cola_wh/article/details/115326789