【问题标题】:Navigation bar overlapped by status bar导航栏与状态栏重叠
【发布时间】:2013-02-04 20:02:03
【问题描述】:

我在iOS 6.0iOS 6.0.1 上遇到了一个非常奇怪的问题。

每当我从任何视图控制器呈现模态视图然后关闭该模态视图时,我的父视图控制器的导航栏(从我呈现模态视图的位置)与状态栏重叠。这在iOS 6.0iOS 6.1 Simulators 上运行良好,但在设备上却搞砸了。

我的 Xcode 版本是 4.6。

这就是我展示我的模态的方式:

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

这就是我解除模态的方式:

[self dismissModalViewControllerAnimated:YES];

请在关闭模式后查看我的导航栏的截图:

【问题讨论】:

    标签: iphone ios objective-c xcode cocoa-touch


    【解决方案1】:

    我把它修好了。这是因为当我的 RootViewController 启动时,它会延迟旋转直到动画完成。完成后,它会再次允许旋转。问题是它在所有方面(包括肖像)都返回 NO。视图显示得很好,但是当我展示一个模态并返回时,视图几何图形被破坏了。一旦我将其更改为即使在动画期间也为纵向模式返回 YES,问题就消失了。

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

    【讨论】: