Swiftのhyperoslo/ImagePickerを使うと落ちます。

投稿者: Anonymous

https://github.com/hyperoslo/ImagePicker
を使うと落ちます。

開発環境
Xcode 10.2 (10E125)
Deployment Target: 12.2

その他必要な情報があれば教えてください。

import UIKit
import ImagePicker

class ViewController: UIViewController, ImagePickerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func addBtnTapped(_ sender: Any) {
        choosePicture()
    }

    @objc func choosePicture() {
        let config = Configuration()
        config.doneButtonTitle = "Finish"
        config.noImagesTitle = "Sorry! There are no images here!"
        config.recordLocation = false
        config.allowVideoSelection = true

        let imagePicker = ImagePickerController(configuration: config)
        imagePicker.delegate = self

        present(imagePicker, animated: true, completion: nil)//<-###ここで落ちる
    }

    // MARK: - ImagePickerDelegate
    func cancelButtonDidPress(_ imagePicker: ImagePickerController) {
        imagePicker.dismiss(animated: true, completion: nil)
    }

    func wrapperDidPress(_ imagePicker: ImagePickerController, images: [UIImage]) {
        guard images.count > 0 else { return }

        print(images)
    }

    func doneButtonDidPress(_ imagePicker: ImagePickerController, images: [UIImage]) {
        imagePicker.dismiss(animated: true, completion: nil)
    }
}

画像の説明をここに入力

解決

Info.plistに

Privacy - Photo Library Usage Description

Privacy - Camera Usage Description

を追加したら解決しました!

回答者: Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *