方式一: 将自定义控件添加到self.tabBarController.view上,然后使用self.tabBarController.selectedIndex = 2;即使用selectedIndex属性来设置要跳转到哪个tabBarController的子控制器。
方式二: 使用切换window的根控制器来强制跳转:
//BMTabBarViewControlle继承至tabBarController
BMTabBarViewController *tabBarVC = [[BMTabBarViewController alloc] init];
tabBarVC.selectedIndex= 2;//selectedIndex是几就跳转到哪个界面
[UIApplication sharedApplication].keyWindow.rootViewController = tabBarVC;
方式三: 使用tabBarController和tabBarController子控制器为UINavigationController push出来的某一或n级子界面:
//获得tabBarController第4个子控制器的最底层UINavigationController(子控制器是由UINavigationController push出来的控制器)
UITabBarController *rootVC = self.tabBarController;
[self.navigationController popToRootViewControllerAnimated:false];
[rootVC setSelectedIndex:3];
UINavigationController *nav = [rootVC selectedViewController];
//利用上面获得的nav来push子控制器
LB_SceneWebController *vc = [LB_SceneWebController new];
NSDictionary *params = @{@"currRole" : App_User_Info.myInfo.userModel.currentRole,
@"currRoleId" : str(App_User_Info.myInfo.businessModel.businessId)};
vc.url = [URLService web_myCreatedScene:params];
vc.hidesBottomBarWhenPushed = YES;
[nav pushViewController:vc animated:YES];