Commit 207e661f authored by luyueming's avatar luyueming

修改获取当前控制器

parent 8cd23190
......@@ -19,36 +19,18 @@
+ (UIViewController *)getCurrentViewController{
UIViewController* currentViewController = [self getRootViewController];
BOOL runLoopFind = YES;
while (runLoopFind) {
if (currentViewController.presentedViewController) {
if (currentViewController.presentedViewController) { //present
currentViewController = currentViewController.presentedViewController;
} else if ([currentViewController isKindOfClass:[UINavigationController class]]) {
UINavigationController* navigationController = (UINavigationController* )currentViewController;
currentViewController = [navigationController.childViewControllers lastObject];
} else if ([currentViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController* tabBarController = (UITabBarController* )currentViewController;
currentViewController = tabBarController.selectedViewController;
} else {
NSUInteger childViewControllerCount = currentViewController.childViewControllers.count;
if (childViewControllerCount > 0) {
currentViewController = currentViewController.childViewControllers.lastObject;
return currentViewController;
} else if ([currentViewController isKindOfClass:NSClassFromString(@"WMMainTabBarViewController")]) { //一级页面
UIViewController *vc = (UIViewController *)[currentViewController valueForKey:@"current"];
return vc;
} else {
UINavigationController* navigationController = (UINavigationController* )currentViewController;
currentViewController = navigationController.visibleViewController;
return currentViewController;
}
}
}
return currentViewController;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment