ios - UITabBarController 中的双 UINavigationBar

标签 ios objective-c iphone uitabbarcontroller uinavigationbar

我们在 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 时,我们会在 landscapeportrait< 的顶部获得 2 个 UINavigationBar/ 模式。

检查下图。

enter image description here

enter image description here

并且 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/

相关文章:

Objective-c 序列化字典与 Node js 服务器

objective-c - ios6 mapkit错误模拟器

iphone - 将 iPhone 应用程序转换为通用,在 XCode 4.2 中找不到 "File->Create iPad version"

iphone - 通用 iPhone/iPad 应用程序大小问题

ios - 如何让 UiButton 的右侧始终位于屏幕中央?

iphone - 辅助线程的堆栈大小,DEBUG 和 RELEASE 版本之间的显着差异

ios - 在 UIScrollView iOS7 中延迟加载图像时内存增加

ios - uicollectionview 的动态高度根据行值

iPhone SDK - 如何判断动画何时完成?

ios - UISearchController 的自定义单元格