我正在使用 Storyboard为 iOS 5 进行编程。 我正在尝试创建一个带有导航 Controller 的应用程序。 在我的应用程序中,我希望某些 View Controller 具有导航栏,而有些则没有。
我正在使用以下link作为我创建一个的指导。
这就是我以编程方式隐藏导航栏的方式:
在 MyAppDelegate 中我声明了一个变量:
UINavigationController *navigationController;
@property (strong, nonatomic) IBOutlet UINavigationController *navigationController;
在我的 UIViewController(第一个 UIViewController)中,我执行了以下操作
- (void)viewDidload
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
但这不起作用...
如何让它发挥作用?
最佳答案
拉杰,
尝试将这两个函数添加到您的 UIViewController 中:
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
关于ios5 - 隐藏 ios 5 导航 Controller 中的默认导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9870463/