UInavigationController内部的UitabbarController的popview
-
03-10-2019 - |
题
我正在基于XCode的实用程序模板构建应用程序,我添加了更多视图。我的应用结构将如下:
MAINVIEW(应用程序菜单)
翻转侧视图(计算器)
uinavigationController
设置视图
ViewDidload:UitabbarController
- Tab1 view (options) - Tab2 view (information text)
我可以从我的主视图正确导航到翻转侧视图,这也是导航控制器的根视图。从我的另一侧视图中,我推出导航控制器(设置视图)的第二视图,该视图配置为显示一个带有两个选项卡的UitabbarController(带有ViewDidload)。
如果我删除了uitabbarcontroller,则可以使用“ popviewController”从我的设置视图中返回而没有问题。如果我在设置视图中加载uitabbarcontroller在ViewDidload中加载UitabbarController,则问题出现。这些选项卡完美工作,但是我无法返回我的翻转侧视图(导航控制器的根视图)。
如果使用导航控制器的导航栏,我可以返回,但是我想配置自己的按钮并隐藏导航栏。
到目前为止,我尝试了以下方法:
self.navigationController popviewControllerAnimated:yes];
self.navigationController poptorootViewControllerAnimated:yes];
self.navigationController popToviewController:flipsideViewController animation:yes];
但是他们似乎不起作用。前两个什么都不做(屏幕保留原样),第三个没有识别“ FlipsideViewController”(也许是因为它是MainViewController的代表?)。
是否有办法检查导航栏的“背部”按钮,如果我激活它?
我应该使用代表吗?
我可以从两个选项卡视图中的任何一个中的任何设置视图中调用PopviewController方法吗?
这是我的另一面视图:
- (IBAction)showSettingsView {
SettingsViewController *controller = [[SettingsViewController alloc] initWithNibName:@"SettingsView" bundle:nil];
controller.title = @"Settings";
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
这是我的设置视图:
- (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];
}
以及在标签视图之一中返回的方法:
- (IBAction)backFromTab1View {
[self.navigationController popToViewController:FlipSideViewController animated:YES];
}
非常感谢,很抱歉,如果问题太基本!
解决方案
实际上,我解决了在“设置视图”中创建自己的uinavigationbar的问题,并使用:
[self.view insertSubview:tabBarController.view belowSubview:myNavigationBar];
这插入了导航栏下方的其余视图,我仍然可以使用它来配置一个弹出视图并返回上一个屏幕的按钮。
我花了一段时间才意识到“ addsubview”和“ insersubview + belowsubview”之间的差异。对于那个很抱歉!