The only allowed orientation in my app is landscape. I force this in the project properties under target > summery and only allow portrait in shouldAutorotateToInterfaceOrientation
The problem is when I take a picture while holding the phone horizontally (landscape), the photo will be taken in landscape orientation, while the UI remains in portrait mode.
This means in landscape mode I get a wide image of 3264 x 2448 instead of the tall image (2448 x 3264) I get in portrait mode.
Next the user can crop the image, but if the image is taken in landscape mode I get very ugly stretched images. Adding borders or switching the UI to landscape is not an option.
Is there a way to force the UIImagePickerController
to take a photo in portrait dimensions even though the phone is held horizontally (landscape mode)?
I initialize the UIImagePickerController
with the following settings:
imagePicker =[[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
imagePicker.showsCameraControls = NO;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
imagePicker.wantsFullScreenLayout = YES;
imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform,CAMERA_TRANSFORM, CAMERA_TRANSFORM);
imagePicker.navigationBarHidden = YES;
imagePicker.toolbarHidden = YES;
[self presentModalViewController:imagePicker animated:NO];
imagePicker.cameraOverlayView = self.cameraOverlay;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff;