导航栏与状态栏重叠 [英] Navigation bar overlapped by status bar

查看:597
本文介绍了导航栏与状态栏重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 iOS 6.0 & iOS 6.0.1

每当我从任何视图控制器呈现模态视图,然后关闭模态视图,我的父视图控制器(从我提出的模态视图)的导航栏重叠的状态栏。这在 iOS 6.0 & iOS 6.1 模拟器,但在设备上混乱。

Whenever I present a modal view from any view controller and then dismiss that modal view, the navigation bar of my parent view controller (from where I presented the modal view) overlaps by the status bar. This is working fine on iOS 6.0 & iOS 6.1 Simulators but on devices it messes up.

我的 Xcode 版本是4.6。

模式:

UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:iViewController];
[aNavigationController.navigationBar setBarStyle:UIBarStyleBlack];
[self presentModalViewController:aNavigationController animated:YES];
[aNavigationController release];

这是我解雇我的Modal的方式:

This is how I am dismissing my Modal:

[self dismissModalViewControllerAnimated:YES];

关闭模态后,请查看我的导航栏的屏幕截图:

Please see the attached screenshot of my nav bar after dismissing the modal:

推荐答案

我得到了固定。这是因为当我的RootViewController启动时,它持续关闭旋转,直到动画完成。一旦完成,它再次允许旋转。问题是,它返回NO所有方面(包括肖像)。视图显示很好,但是当我将呈现模态和回报,视图几何被破坏。一旦我改变它为纵向模式返回YES,即使在动画,问题消失了。

I got it fixed. This was because when my RootViewController launches it holds off on rotations until the animation is done. Once it is done, then it allows rotations again. The problem was that it was returning NO for all aspects (including portrait). The view showed fine but when I would present a modal and return, the view geometry was mangled. Once I changed it to return YES for portrait mode even during animation, the problem went away.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)iOrientation {
    return (iOrientation == UIInterfaceOrientationPortrait);
}

这篇关于导航栏与状态栏重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆