[英]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.