我正在构建一个基于Xcode中的Utility模板的应用程序,我已经添加了一些更多的视图。我的应用程序的结构将是如下:来自UITabBarController内的popView UINavigationController
的MainView(应用菜单)
倒装侧视图(一个计算器)
的UINavigationController
设置视图
viewDidLoad中:的UITabBarController
- Tab1 view (options) - Tab2 view (information text)
我可以从我的MainView到我的翻转侧视图,这也是导航控制器的根视图正确地导航。从我的Flip侧视图中,我推入导航控制器(设置视图)的第二个视图,该视图配置为一旦加载(使用viewDidLoad),就会显示带有两个选项卡的UITabBarController。
如果我删除了UITabBarController,我可以使用“设置”视图中的“popViewController”将没有问题的问题返回到我的翻转视图。如果我在我的Settings视图中加载viewDiDLoad中的UITabBarController,这个问题就出现了......这些标签完美地工作,但我无法再返回到我的Flip-side视图(导航控制器的根视图)。
我可以返回,如果我使用导航栏的导航控制器,但我想配置我自己的按钮,并隐藏导航栏。
到目前为止,我已经尝试以下方法:
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
[self.navigationController popToViewController:FlipSideViewController animated:YES];
但他们似乎没有工作。前两个不做任何事情(屏幕保持原样),第三个不承认“FlipsideViewController”(也许是因为它是MainViewController的委托?)。
如果我激活导航栏,是否有方法检查导航栏的“返回”按钮?
我应该使用代表吗?
我可以在两个Tab视图中的任何一个设置视图中调用popViewController方法吗?
这是我的倒装侧视图:
- (IBAction)showSettingsView {
SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsView" bundle:nil];
controller.title = @"Settings";
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
这是我的设置查看:
- (IBAction)backFromTab1View {
[self.navigationController popToViewController:FlipSideViewController animated:YES];
}
:
- (void)viewDidLoad {
[super viewDidLoad];
tabBarController = [[UITabBarController alloc] init];
Tab1ViewController* vc1 = [[Tab1ViewController alloc] init];
Tab2ViewController* vc2 = [[Tab2ViewController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
tabBarController.viewControllers = controllers;
[self.view addSubview:tabBarController.view];
}
而且方法中的标签视图之一返回
非常感谢,如果问题太简单,我们会很抱歉!