如何在 UINavigationController 中嵌入 UITabBarController?
How to embed UITabBarController inside UINavigationController?
我想在 UINavigationController
中嵌入 UITabBarController
。我找到了 a similar question here on Whosebug,但我尝试的实现不允许我将 UIBarButtonItem
添加到 navigationItem.rightBarButtonItems
。
下面是我的实现截图。 "Button 1" 和 "Button 2" 未显示在 运行 应用程序中。知道我做错了什么吗?
我认为你的 "Button 1" 和 "Button 2" 不可见,因为它们被根导航控制器的导航栏重叠了。
所以你可以这样做:
第 1 步。创建一个 UITabBarController
子类并在 IB 中将其分配给您的标签栏控制器。
第 2 步。在 -viewWillAppear:
方法中只隐藏根导航控制器的导航栏
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
第 3 步:返回根视图时带回导航栏
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
我想在 UINavigationController
中嵌入 UITabBarController
。我找到了 a similar question here on Whosebug,但我尝试的实现不允许我将 UIBarButtonItem
添加到 navigationItem.rightBarButtonItems
。
下面是我的实现截图。 "Button 1" 和 "Button 2" 未显示在 运行 应用程序中。知道我做错了什么吗?
我认为你的 "Button 1" 和 "Button 2" 不可见,因为它们被根导航控制器的导航栏重叠了。
所以你可以这样做:
第 1 步。创建一个 UITabBarController
子类并在 IB 中将其分配给您的标签栏控制器。
第 2 步。在 -viewWillAppear:
方法中只隐藏根导航控制器的导航栏
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
第 3 步:返回根视图时带回导航栏
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:NO animated:animated];
}