【发布时间】:2010-11-16 07:12:10
【问题描述】:
我正在尝试将一个 UITabBar 嵌套在另一个中,如下所示:
UITabBarController *tabController = [[UITabBarController alloc] init];
tabController.delegate = self;
UITabBarController *friendsTabController = [[UITabBarController alloc] init];
FindFriendsViewController *findFriendsController = [[FindFriendsViewController alloc] initWithNibName:@"FindFriendsViewController" bundle:nil];
findFriendsController.rootViewController = self;
UINavigationController *findFriendsNavController = [[UINavigationController alloc] initWithRootViewController:findFriendsController];
findFriendsNavController.tabBarItem.title = NSLocalizedString(@"Add", nil);
friendsTabController.viewControllers = [NSArray arrayWithObjects:friendStreamController, friendListController, findFriendsNavController, nil];
tabController.viewControllers = [NSArray arrayWithObjects:nearbyNavController, friendsTabController, meController, checkInController, logController, nil];
(显然,为了简洁,省略了一些代码,例如其他选项卡)
当我这样做时,点击外部标签栏的“朋友”标签,内部标签栏直接出现在外部标签栏的上方。我不想要这个。我希望内部标签栏在被选中时取代外部标签栏(在窗口底部)。
我已经尝试通过隐藏外部标签栏来做到这一点,通过在 UITabBarController 委托方法中将其设置为隐藏,并且我尝试将内部标签栏的框架设置为手动将其定位在屏幕底部像这样:
friendsTabController.tabBar.frame = CGRectMake(0, 430, 320, 50);
当我隐藏外部标签栏时,内部标签栏仍然显示与屏幕底部边缘相同的距离,而外部标签栏将替换为空白矩形。
当我尝试设置内部标签栏的框架时,唯一可见的部分是外部标签栏框架之外的任何部分。
我试过谷歌搜索无济于事。这种导航肯定不是那么罕见吧?在尝试之前,我假设 SDK 会支持它。
有什么想法吗?
TIA,
汤姆
【问题讨论】:
标签: iphone uitabbarcontroller nested