1

I'm updating an app for iOS 13 support and one of the requirements (for now) is to convert all of the modal UIViewControllers back to UIModalPresentationStyle.fullScreen, but the UIImagePickerController does not seem to respect the value I'm passing it and is always in "Card View" when I'm picking photos and in fullScreen when I'm picking videos.

Is there a way to make both ViewControllers have the same appearance, either as cards or fullscreen?

Lucas P.
  • 4,282
  • 4
  • 29
  • 50
  • Thank you @matt for the clarification. – Lucas P. Nov 21 '19 at 18:41
  • I rarely disagree with @matt, so maybe I'm misunderstanding the question. I just tested things and when `sourceType = .photoLibrary` and `modalPresentationStyle = .fullScreen` the picker is limited to photos and is presented full screen in iOs 13. what am I missing? –  Nov 21 '19 at 19:52
  • @dfd Hmmm. In my project, `sourceType = .photoLibrary` and `modalPresentationStyle = .fullScreen` and I still get the card apperance, so maybe I'm the one who's missing something. I'll check it again and get back at you. – Lucas P. Nov 22 '19 at 11:59
  • 2
    I was experiencing the same issue with UIImagePickerViewController until I realized that setting `picker.presentationController?.delegate` to a value would cause the modal presentation style setting to be ignored. It worked as expected when I didn't set that delegate property. – William Chen Feb 03 '20 at 21:33

1 Answers1

1

Not looking at this as an answer, just help. Here's my working code written in Xcode 11.2 targeting iOS 13.0:

class ViewController: UIViewController {

    let imagePicker = UIImagePickerController()
    var btnOpenImage = UIButton()

    override func viewDidLoad() {
        super.viewDidLoad()

        btnOpenImage.translatesAutoresizingMaskIntoConstraints = false
        btnOpenImage.backgroundColor = UIColor.red
        btnOpenImage.setTitle("Show Picker", for: .normal)
        btnOpenImage.addTarget(self, action: #selector(showImagePicker), for: .touchUpInside)
        view.addSubview(btnOpenImage)

        btnOpenImage.widthAnchor.constraint(equalToConstant: 180).isActive = true
        btnOpenImage.heightAnchor.constraint(equalToConstant: 80).isActive = true
        btnOpenImage.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
        btnOpenImage.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
    }
}
extension ViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    @objc func showImagePicker() {
        imagePicker.allowsEditing = false
        imagePicker.sourceType = .photoLibrary
        imagePicker.modalPresentationStyle = .fullScreen
        present(imagePicker,
                animated: true,
                completion: nil)
    }
    @objc internal func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        dismiss(animated: true, completion: nil)
    }
    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        dismiss(animated: false, completion: nil)
    }
}

It doesn't do much, but it does show things full screen. It was pulled from a much larger project and tested on an iPad Mini running 13.1, and another running 13.2. Also tested in the iPhone 11 Pro simulator.

One thing, while I added the NSPhotoLibraryUsageDescription key to info.plist, it never actually popped anything up!?!