我们在 AppDelegate
中有一个 UINavigationViewController
作为根 viewController
:
Restore *callRestore=[[Restore alloc]initWithNibName:@"Restore" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:callRestore];
self.window.rootViewController = self.navigationController;
我们正在从上面推送一个新的 viewController
(TabViewController
) 恢复:
callTabView=[[TabViewController alloc] initWithNibName:@"TabViewController" bundle:nil];
[self.navigationController pushViewController:callTabView animated:YES];
在这个 TabViewController
中,我们以编程方式添加 UITabBarController
作为 subview ,在这个 UITabBarController
中,我们有 5 个 UINavigationBarController
作为 View Controller :
NSArray* controllers = [NSArray arrayWithObjects:navControllerDashboard, navControllerAccounts, navControllerTransation,navControllerCallDisplayReports,navControllerMore, nil];
self.tabBarController.viewControllers = controllers;
self.tabBarController.delegate = self;
self.tabBarController.view.frame = self.view.frame;
[self.view addSubview:self.tabBarController.view];
当我们从这 5 个 UINavigationViewController
旋转任何 View 时,我们会在 landscape
和 portrait< 的顶部获得 2 个
模式。 UINavigationBar
/
检查下图。
并且 didRotateFromInterfaceOrientation 不是从这 5 个 UINavigationViewController View 调用。
有什么帮助吗?
最佳答案
当您手动将一个 View Controller 作为 subview 添加到另一个 View Controller 时,您必须执行以下操作:
UIViewController *parent = ...;
UIViewController *child = ...;
[child willMoveToParentViewController: parent];
[parent addChildViewController: child];
[parent.view addSubview: child.view];
[child didMoveToParentViewController:parent];
这会将所有事件传播到 subview Controller 并可能消除意外行为。
关于ios - UITabBarController 中的双 UINavigationBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39344021/