UIImagePickerController不是全屏

Wim*_*tra 7 cocoa-touch objective-c ios ios7

自iOS7升级以来,我有一种奇怪的行为了UIImagePickerController.在这个应用程序中我使用的UIImagePickerController是a cameraOverlayView.

在iOS6中,我UIImagePickerController使用以下代码调用:

_picker = [[UIImagePickerController alloc] init];

if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear]) {
    _picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    _picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    _picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    _picker.showsCameraControls = NO;
    _picker.navigationBarHidden = NO;
    _picker.toolbarHidden = YES;
    _picker.wantsFullScreenLayout = YES;

    _overlayViewController = [[OverlayViewController alloc] init];
    _overlayViewController.picker = _picker;
    _overlayViewController.frameSize = self.frameSize;
    _overlayViewController.delegate = self;
    _picker.cameraOverlayView = _overlayViewController.view;
}
else {
    _picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

}
_picker.delegate = self;
Run Code Online (Sandbox Code Playgroud)

其中OverlayViewControllerUIViewController一个透明背景,在屏幕上绘制一些自定义控件.

在此输入图像描述

但是现在在iOS 7中,相机通过状态栏绘制,并且在实时摄像机视图下方会出现黑条.

我可以通过应用解决这一CGAffineTransformMakeTranslationcameraViewTransform的特性UIImagePickerController,但是这是为什么这样呢?

小智 1

在 iOS 7 中,默认情况下 UIViewController 视图占据整个屏幕区域,包括状态栏。

wantsFullScreenLayout
Run Code Online (Sandbox Code Playgroud)

已被弃用并被忽略。在某些情况下,此修复有效(在视图控制器类中):

if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
    [self setEdgesForExtendedLayout:UIRectEdgeNone];
}
Run Code Online (Sandbox Code Playgroud)

在其他情况下,情况会稍微复杂一些。现在已经很晚了,看你怎么处理。需要注意的有用事项 - 在 UIViewController 中,以下代码将在 iOS 6 和 iOS 7 上提供正确的状态栏高度,如果必须使用 CGRect 数学来对齐内容:

if (UIDeviceOrientationIsLandscape(self.interfaceOrientation)) {
            statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.width;
        } else {
            statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
        }
Run Code Online (Sandbox Code Playgroud)

然后不要忘记,在 Interface Builder 中,有新的“iOS 6 delta”调整,允许您针对 iOS 7 进行设计,然后使用偏移量来纠正 iOS 6。

无论如何,让我知道你进展如何。