gpt4 book ai didi

ios - UIImagePickerController 不是全屏

转载 作者:可可西里 更新时间:2023-11-01 03:34:33 26 4
gpt4 key购买 nike

自从 iOS7 升级后,UIImagePickerController 出现了奇怪的行为。在此应用程序中,我使用带有 cameraOverlayViewUIImagePickerController

在 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;

OverlayViewController 是一个 UIViewController,具有透明背景,可在屏幕上绘制一些自定义控件。

enter image description here

但现在在 iOS 7 中,相机是通过状态栏绘制的,并且在实时相机 View 下方会出现一个黑条。

我可以通过将 CGAffineTransformMakeTranslation 应用于 UIImagePickerControllercameraViewTransform 属性来解决这个问题,但为什么会这样?

最佳答案

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

wantsFullScreenLayout

已弃用并被忽略。在某些情况下,此修复有效(在 View Controller 类中):

if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}

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

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

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

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

关于ios - UIImagePickerController 不是全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19006272/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com