简体   繁体   English

在基于导航的应用程序-iphone中在选定视图中隐藏导航栏

[英]hide navigation bar in selected view in navigationbased application-iphone

I am working on application, I had made application navigationbased. 我正在开发应用程序,我已经使应用程序基于导航。 I want to hide navigation bar from the selected view only how can i do that? 我只想从所选视图中隐藏导航栏,我该怎么做? i used following code but it hides the bar from whole application self.navController.navigationBarHidden = YES; 我用下面的代码,但它从整个应用程序中隐藏了酒吧self.navController.navigationBarHidden = YES;

If there is any way please let me know.. 如果有任何办法,请告诉我。

Thanks in advance 提前致谢

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

on view which you want navigation controller use 在要导航控制器使用的视图上

self.navigationController.navigationBar.hidden=YES;

this in viewWillAppear 这在viewWillAppear

And

self.navigationController.navigationBar.hidden=NO;

in viewWillDisappear method of same view 在同一视图的viewWillDisappear方法中

In the selectedView hide the navigation controller when main view didLoad and unhide that when view will dissappear 在selectedView中,当主视图didLoad时隐藏导航控制器,并在视图消失时取消隐藏

eg:- In selectedView.m 例如:-在selectedView.m中

- (void)viewDidLoad {
    [super viewDidLoad];
[[self navigationController] setNavigationBarHidden:YES animated:NO];
}

and

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[self navigationController] setNavigationBarHidden:NO animated:NO];
}

now by doing this u will not get navigation controller in selectedView but get that in other views...For more corcern try to take help from already asked how to work without with navigation controller 现在通过执行此操作,您将不会在selectedView中获得导航控制器,而是在其他视图中获得...更多关注,请尝试从已经被问到的不使用导航控制器的情况下获得帮助

Hope this may help u....Good luck!!! 希望这对你有帮助。

Try with this code, 试试这个代码,

self.navigationController.navigationBar.hidden=YES;

Good Luck 祝好运

You have to write below code in that controller in which you want to hide your Navigation bar... 您必须在要隐藏导航栏的控制器中编写以下代码...

self.navigationController.navigationBar.hidden=YES; self.navigationController.navigationBar.hidden = YES;

and you have to write below code in which you want to show Navigation bar... 并且您必须在下面的代码中显示导航栏...

self.navigationController.navigationBar.hidden=NO; self.navigationController.navigationBar.hidden =否;

write both code in respective viewWillAppear ... 将两个代码分别写入viewWillAppear ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM