带导航控制器的 Tabbar 控制器
我在导航控制器中添加视图控制器,然后将其添加到选项卡栏控制器。但如果我添加这样的内容,
navigationController.viewControllers =
[NSArray arrayWithObjects:rootViewController, rootViewController.photoViewController, nil];
tabBarController.viewControllers = [NSArray arrayWithObjects:tourNavigation,mapNavigation ,browserNavigation,
navigationController,nil];
这不会显示带有第四个导航控制器的选项卡..其他控制器很简单,因为
BrowserViewController *browserView = [[BrowserViewController alloc]initWithNibName:@"BrowserViewController"
bundle:nil];
browserView.title = @"Browser";
UINavigationController *browserNavigation = [[[UINavigationController alloc]initWithRootViewController:browserView]
autorelease];
这工作正常..但是使用数组的导航不显示。
I am adding view controller in navigation controller and then adding it to tab bar controller. but if i add this like
navigationController.viewControllers =
[NSArray arrayWithObjects:rootViewController, rootViewController.photoViewController, nil];
tabBarController.viewControllers = [NSArray arrayWithObjects:tourNavigation,mapNavigation ,browserNavigation,
navigationController,nil];
This is not showing tab with fourth navigation controller.. other controllers are simple as
BrowserViewController *browserView = [[BrowserViewController alloc]initWithNibName:@"BrowserViewController"
bundle:nil];
browserView.title = @"Browser";
UINavigationController *browserNavigation = [[[UINavigationController alloc]initWithRootViewController:browserView]
autorelease];
This is working fine.. but navigation with array is not displaying.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您不应该像这样设置导航控制器的 viewControllers 数组。相反,请尝试:
假设您希望在用户点击选项卡时显示照片视图控制器。它将位于导航控制器堆栈的顶部。
I don't think you should be setting the navigation controller's
viewControllers
array like that. Instead try:This is assuming that you want the photo view controller to be showing when the user taps on the tab. It will be on top of the navigation controller's stack.
您需要从基于视图的应用程序开始。然后在 appDelegate 文件中创建一个 UITabbarController。
Appdelegate.h
Appdelegate.m
您可以相应地管理要在哪个选项卡中放置导航控制器或仅放置视图控制器。
然后在上面提到的每个视图控制器中,您需要实现
可以设置选项卡名称和图像的功能。
You need to start with view based application. And then create a UITabbarController in you appDelegate file.
Appdelegate.h
Appdelegate.m
You can accordingly manage in which tab you want to place navigation controller or only a view controller.
Then in each of the view controllers mentioned above you need to implement
in which you can set Tab name and image.