简体   繁体   English

导航栏位于隐藏的状态栏下方

[英]Navigationbar is positioned below the hidden statusbar

coming from a TableView, I am creating an MKMapView. 来自TableView,我正在创建MKMapView。 I want to have more screen real estate, so I hide the status bar und set the navigation bar to transluscent. 我想拥有更多的屏幕空间,所以我隐藏了状态栏并将导航栏设置为半透明。

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.translucent = NO;

Unfortunaltely the navigation bar is positioned below the hidden status bar (see picture). 不幸的是,导航栏位于隐藏状态栏的下方(参见图片)。

在此处输入图片说明

I already found out that this might help, since one can perform kind of a reload of the bar in the main event loop: 我已经发现这可能会有所帮助,因为可以在主事件循环中执行某种方式的酒吧重新加载:

[self performSelector:@selector(setNavigationController:YES) withObject:nil afterDelay:0.1];

But this doesn't work so far. 但这到目前为止还行不通。 Any hint? 有什么提示吗?

Thanks in advance. 提前致谢。

Okay, I found out what to do: 好的,我知道该怎么做:

[self performSelector:@selector(setNavigationController:NO) withObject:nil afterDelay:0.1];
[self performSelector:@selector(setNavigationController:YES) withObject:nil afterDelay:0.1];

This switches the navigation bar off and on again, which forces it to redraw in the correct position. 这会关闭并再次打开导航栏,这迫使它重新绘制到正确的位置。

I use this in iOS 6: 我在iOS 6中使用它:

self.navigationController.navigationBarHidden = YES;
self.navigationController.navigationBarHidden = NO;

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

相关问题 隐藏状态栏的Chartboost - Chartboost with statusbar hidden 如何同时滑入/退出statusBar和navigationBar? - How to slide in/out statusBar and navigationBar simultaneously? 同时隐藏状态栏和导航栏,就像在图片应用程序中一样 - hide statusbar and navigationbar simultaneously, like in Pictures application NavigationBar定位不正确。 如何解决这个问题呢? - NavigationBar not positioned correctly. How to solve this problem? 没有状态栏的NavigationBar在iOS11中与安全区重叠 - NavigationBar without statusbar overlaps safearea in iOS11 通过push / pop将导航栏设置为隐藏,查看大小调整 - View sizing with setting navigationbar to hidden with push/pop 如何组织导航栏下方的“标签”? 最佳做法? - How to organize “tabs” below the navigationBar? Best practices? 应用进入前景后,隐藏的导航栏重新出现 - Hidden NavigationBar reappears after app enters foreground 是否只隐藏一些UINavigationController的NavigationBar? - Make only some UINavigationController's NavigationBar hidden? self.navigationController.navigationBar.hidden = TRUE; Vs [self.navigationController.navigationBar setHidden:YES]; - self.navigationController.navigationBar.hidden=true; Vs [self.navigationController.navigationBar setHidden:YES];
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM