iOS获取当前显示最顶层的ViewController
作者:
Macanzy | 来源:发表于
2019-10-21 20:02 被阅读0次- (UIViewController*)currentViewController{
UIViewController* vc = [UIApplication sharedApplication].keyWindow.rootViewController;
while (true) {
if ([vc isKindOfClass:[UINavigationController class]]) {
vc = [(UINavigationController *)vc visibleViewController];
} else if ([vc isKindOfClass:[UITabBarController class]]) {
vc = [(UITabBarController *)vc selectedViewController];
} else if (vc.presentedViewController) {
vc = vc.presentedViewController;
}else {
break;
}
}
return vc;
}
本文标题:iOS获取当前显示最顶层的ViewController
本文链接:https://www.haomeiwen.com/subject/yeebrqtx.html
网友评论