【发布时间】:2011-05-21 15:07:54
【问题描述】:
我试图在另一个 TabBarController 之上呈现一个 TabBarController。我的应用程序的 MainWindow.xib 如下所示:
Files Owner
First Responder
My App App Delegate
Window
TabBarContoller
+TabBar
+Nav Controller Subclass (a custom class)
+Navigation Bar
+Table View Contoller Subclass (custom class)
+Tab Bar Item
+Second View Controller (not yet hooked up)
我正在尝试在 TableView 中单击项目时显示 xib 文件。这个 xib 文件有一个 TabBarController 作为它的主视图,但是当视图显示时,标签栏和导航栏都是不可见的。我用来显示它的代码是:
MyAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.customNavController presentModalViewController:customDetailEditViewController animated:YES];
如果我使用下面的代码将视图控制器推送到堆栈上,我会看到正确的导航栏,但显示的是根视图控制器中的 TabBar,而不是已推送视图中的 TabBar。
[delegate.customNavController pushViewController:customDetailEditViewController animated:YES];
我什至尝试删除 TabBarController 并手动实现我自己的 TabBar 委托,但效果相同(没有 NavigationBar 或 TabBar,或者来自根 ViewController 的 NavigationBar/TabBar)。
编辑:我已将源上传到 http://mi6.nu/tabcontroller.zip 。如果对 iOS 有更多经验的人可以看看,我将不胜感激。
EDIT2:到目前为止,我最接近的是在第一个标签栏中显示一个模态视图控制器,所以我的视图如下所示:
NavigationBar
[ ]
[ ]
[---View---]
[ ]
[ ]
TabBar from the pushed view
TabBar from the root view
为了实现这一点,我正在使用:
UITabBarController *tabBarController = [[UITabBarController alloc] init];
UIViewController *directionsView = [[UIViewController alloc] init];
txtDirections = [[UITextView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height)];
[directionsView.view addSubview:txtDirections];
IconPickerViewController *iconPicker = [[IconPickerViewController alloc]init];
tabBarController.viewControllers = [NSArray arrayWithObjects:recipeDetailEditViewController,directionsView,iconPicker, nil];
[directionsView release];
[iconPicker release];
MyAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.rootNavController presentModalViewController:recipeDetailEditViewController animated:YES];
但这只会使一切复杂化,因为 a) 这并不理想,因为我有两个标签栏,b) 所有控件(所有编辑控件)都需要在 TableViewController 中,以便可以加载/保存它们的值以编辑项目。如果推送的视图可以处理加载/保存并显示在根选项卡的顶部,那会容易得多。
这一定是可能的吗?
【问题讨论】:
标签: iphone ios uitabbarcontroller uitabbar modalviewcontroller