Appdelegate 跳转其他页面
UITabBarController *tab = (UITabBarController *)_window.rootViewController;
UINavigationController *nav = tab.viewControllers[tab.selectedIndex];
MessageViewController *vc = [[MessageViewController alloc] init]; 需要跳转的页面
vc.hidesBottomBarWhenPushed = YES;
[nav pushViewController:vc animated:YES];
//获取当前屏幕显示的viewcontroller
- (UIViewController *)getCurrentVC{
UIWindow *window = [[UIApplication sharedApplication].windows firstObject];
if (!window) {
return nil;
}
UIView *tempView;
for (UIView *subview in window.subviews) {
if ([[subview.classForCoder description] isEqualToString:@"UILayoutContainerView"]) {
tempView = subview;
break;
}
}
if (!tempView) {
tempView = [window.subviews lastObject];
}
id nextResponder = [tempView nextResponder];
while (![nextResponder isKindOfClass:[UIViewController class]] || [nextResponder isKindOfClass:[UINavigationController class]] || [nextResponder isKindOfClass:[UITabBarController class]]) {
tempView = [tempView.subviews firstObject];
if (!tempView) {
return nil;
}
nextResponder = [tempView nextResponder];
}
return (UIViewController *)nextResponder;
}
//获取当前屏幕中present出来的viewcontroller。
- (UIViewController *)getPresentedViewController
{
UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topVC = appRootVC;
if (topVC.presentedViewController) {
topVC = topVC.presentedViewController;
}
return topVC;
}
// 获取当前导航控制器
- (BaseNavigationController *)getNavController{
BaseTableBarControllerView *tabVC = (BaseTableBarControllerView *)self.window.rootViewController;
tabVC.selectedIndex = 2;
BaseNavigationController *pushClassStance = (BaseNavigationController *)tabVC.selectedViewController;
return pushClassStance;
}