Using UIImagePickerController in landscape orientation Using UIImagePickerController in landscape orientation ios ios

Using UIImagePickerController in landscape orientation

If you'd like to use UIImagePickerController in landscape mode, use user1673099's answer, but instead of:

- (BOOL)shouldAutorotate{    return NO;}


- (UIInterfaceOrientationMask)supportedInterfaceOrientations{    return UIInterfaceOrientationMaskLandscape;}

and then the picker would open in landscape mode:

enter image description here

But make sure you check Portrait in deployment info:

enter image description here

... and I want to create it in landscape mode too.

One line of code can make a big difference! In the method or function where your IBAction lands:

In Swift,

let imagePickerController = UIImagePickerController()imagePickerController.delegate = self// .overCurrentContext allows for landscape and portrait modeimagePickerController.modalPresentationStyle = .overCurrentContext


UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];[imagePickerController setDelegate:self];[imagePickerController setModalPresentationStyle: UIModalPresentationOverCurrentContext];

Note: This will allow imagePickerController to present it's view correctly, but will may not fix the issue of rotation while it is presented.

Try this way....

As per Apple Document, ImagePicker Controller never Rotate in Landscape mode. You have to use in Portrait Mode only.

For disable Landscape mode only for ImagePicker Controller follow below code:

In your ViewController.m:

Make the SubClass(NonRotatingUIImagePickerController) of Image Picker Controller

@interface NonRotatingUIImagePickerController : UIImagePickerController@end@implementation NonRotatingUIImagePickerController// Disable Landscape mode.- (BOOL)shouldAutorotate{    return NO;}@end

Use as follow

UIImagePickerController* picker = [[NonRotatingUIImagePickerController alloc] init];        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;        picker.delegate = self;   etc.... Just as Default ImagePicker Controller

This is working for me & Let me know if you have any Problem.