.mov文件

时间:2017-11-23 17:11:11

标签: ios swift uiimagepickercontroller

我正在使用UIImagePickerController,这对于使用iPhone相机制作的图像效果很好,但info[UIImagePickerControllerOriginalImage]始终为nil用于使用iPhone相机创建的电影(.mov)

选择器出现在这里:

self.imagePicker.sourceType = .photoLibrary
if let mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary) {
    self.imagePicker.mediaTypes = mediaTypes
}
self.present(self.imagePicker, animated: true, completion: nil)

这里是简单的UIImagePickerControllerDelegate实现:

extension MyTableViewController: UIImagePickerControllerDelegate {
    public func imagePickerController(_ picker: UIImagePickerController,
                                      didFinishPickingMediaWithInfo info: [String: Any]) {
        // ...
        print(info[UIImagePickerControllerEditedImage]) 
            // prints nil
        print(info[UIImagePickerControllerOriginalImage]) 
            // prints nil for .mov files
        print(info[UIImagePickerControllerMediaURL]) 
            // prints the correct file url in file://var/.../*.mov
}

我使用的是真正的设备,iOS11.2。

0 个答案:

没有答案