我正在使用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。