Closed jianmu297 closed 7 years ago
如果你的 rootViewController
是本项目的 VC 的话:
((RTRootNavigationController *)self.window.rootViewController).rt_topViewController
rootvc 是通过initWithRootViewControllerNoWrapping初始化的tabbar,上面的办法貌似不行。。
tabbar 外面有包一层 navigation 的吧,不然怎么 push
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
EnterPointTabbarController* vc = [StoryBoardManager shareManager].enterPointMoudle.tabBarVC;
self.window.rootViewController = [[RTRootNavigationController alloc] initWithRootViewControllerNoWrapping:vc];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];`
以上是rootvc的代码,按照demo的例子写的 tabbarvc就一个tabbarviewcontroller 没套nav
这个不是这么用的。分两种情况来处理:
你需要 push 后保持 tabBar 可见
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main"
bundle:nil];
UITabBarController *tabController = [[RTTabBarController alloc] init];
tabController.viewControllers = @[[[RTRootNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Root"]],
[[RTRootNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Remove"]],
[[RTRootNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Scroll"]],
[[RTRootNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Table"]]];
self.window.rootViewController = tabController;
[self.window makeKeyAndVisible];
}
这时,root 是 tabbar controller 本身
push 后 tabBar 不可见
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main"
bundle:nil];
UITabBarController *tabController = [[RTTabBarController alloc] init];
tabController.viewControllers = @[[[RTContainerNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Root"]],
[[RTContainerNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Remove"]],
[[RTContainerNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Scroll"]],
[[RTContainerNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Table"]],
[[RTContainerNavigationController alloc] initWithRootViewController:[story instantiateViewControllerWithIdentifier:@"Status"]]];
self.window.rootViewController = [[RTRootNavigationController alloc] initWithRootViewControllerNoWrapping:tabController];
[self.window makeKeyAndVisible];
}
这时,tabbar controller 是包在 navigation 中的
恩 我是第二种,只不过代码没有贴出来 这种页面结构下 要取当前显示的vc要怎么写
建议你用一个单例来解决这种问题,如:[PaymentManager sharedManager]
,在业务 VC 上设置 delegate,在 - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
中用那个 manager 回调到 delegate 上。
不过你一定要拿到当前 VC 的话可以这样:
vc = ((RTRootNavigationController *)self.window.rootViewController).rt_topViewController;
恍然大悟,受教了!
如题