0
votes

UIImagePicker is always opening photos app in landscape mode while the controller is in portrait mode, and the device orientation is also portrait. Can anyone please help?

enter image description here

func actionSheet(_ actionSheet: UIActionSheet, didDismissWithButtonIndex buttonIndex: Int) {

    if buttonIndex == 1 {

        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {

            let controller = UIImagePickerController.init()
            controller.sourceType = UIImagePickerControllerSourceType.camera
            controller.delegate = self
            controller.allowsEditing = true
            self.present(controller, animated: true, completion: { () -> Void in

            })
        }
    }
    else if buttonIndex == 2 {

        let controller = UIImagePickerController.init()
        controller.sourceType = UIImagePickerControllerSourceType.photoLibrary
        controller.delegate = self
        controller.allowsEditing = true
        self.present(controller, animated: true, completion: { () -> Void in

        })
    }
}
1
There seems no problem with this. I have made a sample code and it is working fine. dropbox.com/sh/jw7krdlnpxxja1u/AADcv_-kpEGaFokjSbb7IHbRa?dl=0 . Is there anything else that is causing screen rotation?i.AsifNoor
I am doing exactly same as you have done in your Test orientation project, but strange thing is photos app is presenting in Landscape only.Shuja Ud Din
Is there way you can share your code?i.AsifNoor
I have already shared the code above, where Imagepicker is being presented. Is there anything else you need to know?Shuja Ud Din
Can you add this before presenting picker controller.modalPresentationStyle = .overCurrentContext and let me know if that fixed issue.i.AsifNoor

1 Answers

1
votes

Add this line before presenting viewcontroller. hope it will fix the issue

controller.modalPresentationStyle = .overCurrentContext