gar*_*hdn 31 iphone uinavigationbar ipad ios
任何人都可以告诉我如何在我的故事板中隐藏导航栏.我在下面的代码在模拟器中运行时运行正常,但它仍然出现在我的故事板中,这实在令我烦恼,因为它正在弄乱我的图像放置.有人可以帮忙吗?
- (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];
}
Run Code Online (Sandbox Code Playgroud)
在Storyboard视图中,只需选择NavigationController场景,UNCHECK显示导航栏(Attributes Inspector)
使用Swift 3的解决方案
步骤2.将以下代码添加到您的ViewController:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Hide the navigation bar on the this view controller
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Show the navigation bar on other view controllers
self.navigationController?.setNavigationBarHidden(false, animated: animated)
}
Run Code Online (Sandbox Code Playgroud)
小智 5
Follow these step:
1: Go to storyboard
2: Select navigation controller
3: Goto Attribute inspector
4: Under navigation controller bar visibility **Uncheck the Shows navigation Bar***
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25158 次 |
| 最近记录: |