我正在使用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]; } }