我在mainwindow.xib中有以下内容
入口点
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
navController.viewControllers = [NSArray arrayWithObject:tabBarController];
[window addSubview:navController.view];
[window makeKeyAndVisible];
return YES;
}
现在在我正在编写的第一个viewcontroller中
-(void)loadView
{
if(rootAppDelegate==nil)
rootAppDelegate=(tabbarAppDelegate *) [[UIApplication sharedApplication]delegate];
listEmergencyItems= rootAppDelegate.listOfEmergencySectionItems;
self.rootAppDelegate.navController.navigationBarHidden = NO;
[super loadView];
}
在第二个视图控制器中我正在编写
- (void)loadView
{
if(rootAppDelegate==nil){
rootAppDelegate=(tabbarAppDelegate *) [[UIApplication sharedApplication]delegate];
}
listHospitalsItems= self.rootAppDelegate.listOfHospitalsItems;
self.rootAppDelegate.navController.navigationBarHidden = YES;
[super loadView];
}
在运行时,当它第一次加载第一个视图时,我会看到导航栏,我需要导航到详细视图。 当我按下第二个标签栏项目时,我转到第二个视图,导航栏被隐藏。 但是当我按下第一个tabbar项时,即返回第一个viewcontroller。导航栏仍然隐藏。
有什么想法吗?
答案 0 :(得分:0)
导航栏不会显示在第二个视图中,因为两个视图都没有放在navigationcontroller的堆栈上。你想在父语句中使用这样的东西来呈现子视图而不是覆盖loadView
ViewToPresentViewController *myVController = [[ViewToPresentViewController alloc] initWithNibName:@"ViewToPresentViewController"
bundle:nil];
myVController.property = someValue;
[self.navigationController pushViewController:myVController
animated:YES];
[myVController release];
然后,正如我之前所说,你可以使用[self.navigationController setNavigationBarHidden:animated:]