iOS 获取当前控制器ViewController

+ (UIViewController *)getPresentVC
{
    UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *topVC = appRootVC;
    if (topVC.presentedViewController) 
    {
        topVC = topVC.presentedViewController;
    }
    
    return topVC;
}

你可能感兴趣的:(iOS 获取当前控制器ViewController)