简体   繁体   English

隐藏导航栏,显示导航栏

[英]Hide navigationBar, Show navigationBar

I met with a problem. 我遇到了一个问题。 At first some code from AppDelegate. 首先,来自A​​ppDelegate的一些代码。

 - (void)HideMainNavigationBar{
navigCtrl.navigationBarHidden = YES;
}

- (void)ShowMainNavigationBar{
navigCtrl.navigationBarHidden = NO;
}

navigCtrl is my navigation controller. navigCtrl是我的导航控制器。 In my other View Controller I need hide my navigationBar and then show it, to display it correctly. 在我的其他View Controller中,我需要隐藏我的navigationBar,然后将其显示以正确显示。

- (void) moviePlayerWillExitFullScreen:(id)sender {
   NSLog(@"exitfullscreen");
   AppDelegate *ptr = [AppDelegate SharedAppDelegate];
   [ptr HideMainNavigationBar];
   [ptr ShowMainNavigationBar];
}

After that, instead of my custom tabBarButton I saw Back button: 之后,我看到了“返回”按钮,而不是自定义的tabBarButton:

在此处输入图片说明

After tap ob Back button, it disappears, and I see my navigationBar again with my custom button. 点击ob后退按钮后,它消失了,并且使用自定义按钮再次看到了我的navigationBar。 This 'bug' was detected in iOS 5.1, on iOS 4.3.2 everithing is ok. 可以,在iOS 5.1中的iOS 5.1中检测到此“错误”。

This makes me crazy, help please. 这让我发疯,请帮助。

PS I know, that I can use: PS我知道,我可以使用:

self.navigationController.navigationBar.frame = CGRectMake(0, 20, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);

to display navigationBar correctly, but i need to show/hide navigationBar to hide it, while rotating VideoPlayer. 正确显示navigationBar,但在旋转VideoPlayer时需要显示/隐藏navigationBar使其隐藏。

Any ideas? 有任何想法吗? Wait your answers, thanks. 等待您的回答,谢谢。

So, after some manipulations I decided simply to set alpha to my navigationBar. 因此,经过一些操作,我决定将alpha设置为我的navigationBar。

if (SYSTEM_VERSION_LESS_THAN(@"5"))  
            [ptr HideMainNavigationBar];
else self.navigationController.navigationBar.alpha = 0;

I hope it would be useful for someone. 我希望这对某人有用。 See ya. 再见。

I just have posted code dedicated on UINavigationBar appearance management on github. 我刚刚在github上发布了专门用于UINavigationBar外观管理的代码。 check out RRViewControllerExtension , it will solve your problem gracefully. 签出RRViewControllerExtension ,它将优雅地解决您的问题。

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

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