导航栏与状态栏重叠

时间:2013-02-19 23:09:05

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

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

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

我的 Xcode 版本为4.6。

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

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

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

[self dismissModalViewControllerAnimated:YES];

解雇模式后,请参阅导航栏的附带屏幕截图:

enter image description here

1 个答案:

答案 0 :(得分:3)

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

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