[英]How to call tab bar view controller from simple view controller which is embedded in navigation controller?
How can I call TabbarViewControllers connected viewController from simple UIViewController where simple UIViewController is embedded in UINavigationController . 我怎么能叫从简单的UIViewController这里简单的UIViewController嵌入的UINavigationController连接的viewController TabbarViewControllers。 I want same Push and Pop effect which UINavigationController provide when moving one to other viewController. 我想要一个将UINavigationController移到另一个viewController时提供的相同的Push和Pop效果。 After digging in google I find out that pushing tab bar view controller inside navigation stack is not a good way to structure app. 深入研究google后,我发现在导航堆栈中推送标签栏视图控制器不是构建应用的好方法。 I tried creating custom transaction animation but it's not same like UINavigation transaction effect. 我尝试创建自定义交易动画,但它与UINavigation交易效果不同。 Please give some suggestion or solution. 请提供一些建议或解决方案。 Thanks!! 谢谢!!
You can directly set UITabbarController to window's rootViewController. 您可以直接将UITabbarController设置为窗口的rootViewController。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
_tabObj = (TabbarViewController*) [storyboard instantiateViewControllerWithIdentifier:@"TabbarViewController"];
self.window.rootViewController = _tabObj;
Check above code. 检查上面的代码。
as Nirmalsinh 's answer, you could set view controller that conform UITabBarControllerDelegate
as your self.window.rootViewController
, then should have UITabBarController
inside it. 作为Nirmalsinh的答案,您可以将符合UITabBarControllerDelegate
视图控制器设置为self.window.rootViewController
,然后在其中包含UITabBarController
。
var tabBarController: UITabBarController
then you can each of tab's navigation and view controller 然后您可以使用Tab的每个导航和视图控制器
let firstViewController = FirstViewController()
let firstNavigationController = UINavigationController(rootViewController: firstViewController)
// other setter
tabBarController.viewControllers = [
firstNavigationController
]
then inside FirstViewController
, you can call 然后在FirstViewController
,您可以调用
let secondViewController = SecondViewController()
navigationController?.pushViewController(SecondViewController, animated: true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.