2

我面临以下问题,我试图呈现一个 modalViewController 并使其覆盖整个屏幕,例如:

[controller setWantsFullScreenLayout:yes];
[myNavController presentModalViewController:controller animated:yes];

结果是控制器没有覆盖整个屏幕,并且状态栏在顶部可见。我真的不明白为什么会这样。

4

2 回答 2

6

The wantsFullScreenLayout property does not hide the status bar, it makes the view controller get layed out behind it (and also get layed out behind things like navigation bars). An example of this is the built-in Photos app, where a picture appears behind the status and navigation bar:

enter image description here

To make a modal view controller full screen you need to set the modalPresentationStyle property of your view controller to UIModalPresentationFullScreen. With this enabled, you probably don't need or want to set wantsFullScreenLayout.

To hide the status bar you need to use the setStatusBarHidden:withAnimation: method of UIApplication.

于 2012-11-19T14:28:01.703 回答
1

尝试添加这个:

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

此外,如果您希望它始终隐藏并且在应用程序启动时,在您的 plist 文件中,添加Status bar initially hiddenYES.

于 2012-11-19T14:23:14.917 回答