UIImagePickerViewController - A photograph taken in the landscape creates a black bar on top

I am using UIImagePickerViewController ( UIImagePickerControllerSourceTypeCamera ) to take a snapshot in my application. However, when a photograph is taken in landscape, a large black bar appears in the upper part of the image in the upper part of the image as a preview / crop (there is also a thin black bar there). Also -

enter image description here

Here is my code -

 UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentViewController:picker animated:YES completion:NULL]; 

In contrast, when a landscape photograph is selected in a photo album, it is placed in the preview center with black bars at the top and bottom.

Where is it from? How can I get rid of it?

+7
ios objective-c uiimagepickercontroller
source share
1 answer

From

 #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]; } } 
0
source share

All Articles