在非控制器(controller)类中拿到当前的设备上显示的controller

- (UIViewController *)getCurrentVC
{
    UIViewController *currentController = [UIApplication sharedApplication].keyWindow.rootViewController;
    
    while (currentController.presentedViewController) {
        currentController = currentController.presentedViewController;
    }
    return currentController;
}

 

posted @ 2017-03-20 18:37  YouNeedCourage  阅读(185)  评论(0编辑  收藏  举报