1

I am trying to present UIImagePickerController in landscape mode for iPhone 7 and iPhone SE (iPhone 7 Plus and iPad use popover). I create a sub class of UIImagePickerController :

class LandscapeUIImagePickerController: UIImagePickerController {


    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {

        return .landscape
    }



    override var shouldAutorotate: Bool {

        return true
    }


    override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {

        return .landscapeRight
    }

and call it like this :

func importFromGallery(_ sender:UIButton)  {

let imagePicker = LandscapeUIImagePickerController()

imagePicker.modalPresentationStyle = .popover
imagePicker.popoverPresentationController?.sourceView = sender
imagePicker.popoverPresentationController?.sourceRect = sender.bounds
imagePicker.popoverPresentationController?.permittedArrowDirections  = .down

imagePicker.delegate = self
present(imagePicker, animated: true, completion: nil)

}

This custom class works when you check Portrait option in Device Orientation : enter image description here

but I don't want to check this option because it affects to other parts of app like keyboard's accessory view and input view. Is there any possible way to open UIImagePickerController without checking that option ? I unchecked Portrait , but app crashes with this error :

* Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES' * First throw call stack:

I am fine with if image picker opens in portrait I have to disable Portrait option.

iOS.Lover
  • 5,923
  • 21
  • 90
  • 162
  • Hey, Did you find any solution for this issue?I am facing the same issue.Need solution ASAP.Please help if you have resolved the issue.Thanks in advance – Garima Saini Nov 24 '17 at 04:55

0 Answers0