获取当前最顶层的VC

#pragma mark -  获取当前最顶层的ViewController

- (UIViewController*)topVC:(UIViewController*)VC {

if([VC isKindOfClass:[UINavigationControllerclass]]) {

return[selftopVC:[(UINavigationController*)VC topViewController]];

}

if([VC isKindOfClass:[UITabBarControllerclass]]) {

return[selftopVC:[(UITabBarController*)VC selectedViewController]];

}

returnVC;

}

- (UIViewController*)topViewController {

UIViewController*vc = [selftopVC:[UIApplicationsharedApplication].keyWindow.rootViewController];

while(vc.presentedViewController) {

vc = [selftopVC:vc];

}

returnvc;

}

上一篇:iOS引入JavaScriptCore引擎框架(二)


下一篇:IOS QuartzCore核心动画框架