UIImagePickerController iOS8 проблема

Проблема с iPhone6 ​​(iOS 8.1 и iOS 8.1.1) и UIImagePickerController

Я использую код:

self.imagePickerController = [[UIImagePickerController alloc] init];
    [self.imagePickerController setSourceType:UIImagePickerControllerSourceTypeCamera];
    self.imagePickerController.showsCameraControls = NO;
    self.imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceFront;

self.imagePickerController.view.layer.borderWidth = 2;
        self.imagePickerController.view.layer.borderColor = [UIColor redColor].CGColor;

[self presentViewController:self.imagePickerController animated:YES completion:nil];

Но после этого на iPhone6 я вижу вид камеры без нижней части (все нормально на iPhone4s iOS 8.1):

1 ответ

Верхняя часть изображения имеет соотношение 4:3, чтобы подать камеру на полный экран, вы можете сделать следующее.

CGSize screenSize = [[UIScreen mainScreen] bounds].size;
// set the aspect ratio of the camera
float heightRatio = 4.0f / 3.0f;
// calculate the height of the camera based on the screen width
float cameraHeight = screenSize.width * heightRatio;
// calculate the ratio that the camera height needs to be scaled by
float scale = screenSize.height / cameraHeight;

// move the controller to the center of the screen
self.imagePickerController.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenSize.height - cameraHeight) / 2.0);
// concatenate the scale transform
self.imagePickerController.cameraViewTransform = CGAffineTransformScale(self.imagePickerController.cameraViewTransform, scale, scale);
Другие вопросы по тегам