how to do when using UITabBarController
caotian opened this issue · 4 comments
I'm using UITabBarController,each tabbar item is UINavigationController,so I have 4 tabbar items and 4 UINavigationControllers, how can i setNavigationController?
If I'm understanding you correctly, Routable doesn't have an opinion how to do orchestrate multiple navigation controllers, it depends on your app.
for example, you can create a separate Routable
instance for each navigation controller. You could have some kind of block that configures all of them with the same routes, i.e.:
NSMutableArray *routers = [NSMutableArray new];
for (UINavigationController *navVc in @[nav1, nav2, nav3]) {
UPRouter *router = [Routable newRouter];
[router map: ...];
[routers addObject: router];
}
Or you could create one router, and only use map: toCallback:
, and that your callback you handle things like opening a certain tab, using a certain navigation controller, etc.
Let me know if that doesn't help
Hi, I applied your idea like:
[[Routable sharedRouter] map:@"routeToItemList2" toController:[ItemListPresenter class]];
[[Routable sharedRouter] map:@"itemList2" toCallback:^(NSDictionary *params) {
self.selectedIndex = 1;
[[Routable sharedRouter] setNavigationController:navigationControllerⅡ];
[[Routable sharedRouter] open:@"routeToItemList2"];
}];
[[Routable sharedRouter] open:@"itemList2"];
but it is not convenient.
There is a more perfect method?
Maybe we need a method like :
map: toController: Callback:
Simply call this delegate method can make it.
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
UINavigationController *navigationConrollerModel = tabBarController.childViewControllers[tabBarController.selectedIndex];
[[Routable sharedRouter] setNavigationController:navigationConrollerModel];
}