工具栏 +导航栏 +分段控制?
我正在尝试找到一种方法来布局应用程序,该应用程序包括底部的选项卡栏、顶部的导航栏以及导航栏上用于切换视图的一行按钮(在第一个选项卡上)。
我画了一个非常粗略的草图(抱歉!),但我希望它能够说明意图。
底部有两个选项卡(tab1 和 tab2)。
当选择 Tab1 时,导航栏将有 3 个按钮,将显示不同的视图(tab1_1、tab1_2、tab1_3)。
当选择 Tab2 时,导航栏不会显示任何按钮,而是一些简单的文本。
此时,我的应用程序委托的 didFinishLaunchingWithOptions 中有以下方案:
UIViewController *viewController1 = [[Tab1_ViewController alloc] initWithNibName:@"Tab1_ViewController" bundle:nil];
UIViewController *viewController2 = [[Tab2_ViewController alloc] initWithNibName:@"Tab2_ViewController" bundle:nil];
tab1NavController = [[UINavigationController alloc] initWithRootViewController:viewController1];
tab2NavController = [[UINavigationController alloc] initWithRootViewController:viewController2];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:tab1NavController, tab2NavController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
我想知道是否需要重做我正在做的事情以实现如图所示的布局。
任何帮助将不胜感激,谢谢!
I'm trying to find a way to layout an application that includes a tab bar on the bottom, a navigation bar on the top, and a row of buttons on the navigation bar that switches views (on the first tab).
I've drawn a very rough sketch (sorry!), but I hope it illustrates the intent.
On the bottom, there are two tabs (tab1, and tab2).
When Tab1 is selected, the navigation bar will have 3 buttons that will show different views (tab1_1, tab1_2, tab1_3).
When Tab2 is selected, the navigation bar won't show any buttons, but rather some simple text.
At this point, I have the following scheme in my application delegate's didFinishLaunchingWithOptions:
UIViewController *viewController1 = [[Tab1_ViewController alloc] initWithNibName:@"Tab1_ViewController" bundle:nil];
UIViewController *viewController2 = [[Tab2_ViewController alloc] initWithNibName:@"Tab2_ViewController" bundle:nil];
tab1NavController = [[UINavigationController alloc] initWithRootViewController:viewController1];
tab2NavController = [[UINavigationController alloc] initWithRootViewController:viewController2];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:tab1NavController, tab2NavController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
I was wondering if I need to redo how I'm doing things in order to achieve the layout as in the picture.
Any help would be appreciated, thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经为我当前的项目做到了这一点...我希望这会对您有所帮助...
首先在您的第一个 viewController [您给出的第一个草图]处使用
UITabbarController
对于您的第一个视图,请使用此代码....
如果您不清楚,请敲...
I have done this for my current project...i hope this will help you....
At first take
UITabbarController
at your first viewController [first sketch you have given]For your first view use this code....
If it is not clear to you then please knock...