獲取當前顯示的viewController
阿新 • • 發佈:2019-01-31
//獲取當前的UIViewController
+ (NSString *)getViewController
{
UIViewController *resultVC = [selftopViewController:[[UIApplicationsharedApplication].keyWindowrootViewController]];
while (resultVC.presentedViewController) {
resultVC = [selftopViewController:resultVC.presentedViewController];
}
NSLog
returnresultVC;
}
+ (UIViewController *)topViewController:(UIViewController *)vc {
if ([vc isKindOfClass:[UINavigationController class]]) {
return [self topViewController:[(UINavigationController *)vc topViewController]];
} elseif ([vc isKindOfClass:[
return [selftopViewController:[(UITabBarController *)vc selectedViewController]];
} else {
return vc;
}
returnnil;
}
iPhone 透明手機殼+全包手機膜+home鍵透明貼+攝像頭保護膜 = 9.9元