ios – UIImagePickerViewController – 在横向拍摄的照片在顶部创建黑色条

前端之家收集整理的这篇文章主要介绍了ios – UIImagePickerViewController – 在横向拍摄的照片在顶部创建黑色条前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用UI ImagePickerViewController(UIImagePickerControllerSourceTypeCamera)在我的应用程序中拍照.但是,当以横向拍摄照片时,预览/裁剪视图中的图像顶部会出现一个大的黑条(底部也有一个细长的黑条).像这样 –

这是我的代码

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

[self presentViewController:picker animated:YES completion:NULL];

相比之下,当从照片库中拾取风景照片时,它将被放置在预览的中心,顶部和底部甚至有黑条.

这是从哪里来的?我怎么摆脱它?

解决方法

this Link
#pragma mark UIImagePickerControllerDelegate

- (void)imagePickerController:(UIImagePickerController *)picker  didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *img = nil;

CGRect cropRect = [[info valueForKey:UIImagePickerControllerCropRect] CGRectValue];

if (cropRect.origin.y < 0) {

    img = [info objectForKey:UIImagePickerControllerOriginalImage];

} else {

    img = [info objectForKey:UIImagePickerControllerEditedImage];

}

}

猜你在找的iOS相关文章