Shuja Ud Din
Shuja Ud Din

Reputation: 434

UIImagePicker opens Photos app in Landscape Mode always

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

        })
    }
}

Upvotes: 0

Views: 194

Answers (1)

i.AsifNoor
i.AsifNoor

Reputation: 587

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

controller.modalPresentationStyle = .overCurrentContext

Upvotes: 1

Related Questions