Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从iOS 11摄像机卷访问HEIC和DNG图片_Ios_Swift - Fatal编程技术网

从iOS 11摄像机卷访问HEIC和DNG图片

从iOS 11摄像机卷访问HEIC和DNG图片,ios,swift,Ios,Swift,我正在通过iOS 11应用程序(用Swift编写)访问原始HEIC和DNG文件;根据Apple开发者的文档,要访问原始文件,只需设置imagePicker.imageExportPreset=UIImagePickerController.ImageURLExportPreset.current,但在UIImagePickerController.InfoKey.imageURL上,我仍然可以得到指向JPEG文件的URL;我知道choosen图片是HEIC和DNG,因为在Mac photo ap

我正在通过iOS 11应用程序(用Swift编写)访问原始HEIC和DNG文件;根据Apple开发者的文档,要访问原始文件,只需设置
imagePicker.imageExportPreset=UIImagePickerController.ImageURLExportPreset.current
,但在
UIImagePickerController.InfoKey.imageURL
上,我仍然可以得到指向JPEG文件的URL;我知道choosen图片是HEIC和DNG,因为在Mac photo app上导出为原始图片时,我会得到原始文件格式

这是我使用的完整代码:

@IBAction func openRoll(_ sender: Any) {
    if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
        let imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = .photoLibrary
        imagePicker.allowsEditing = false
        imagePicker.imageExportPreset = .current
        self.present(imagePicker, animated: true, completion: nil)
    }
}
代表:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    let image = info[UIImagePickerController.InfoKey.originalImage] as! UIImage

    let path = info[UIImagePickerController.InfoKey.imageURL] as! NSURL
    NSLog("URL: \(path.absoluteString)")
    NSLog("Export: \(picker.imageExportPreset.rawValue)")
    dismiss(animated:true, completion: nil)
    // ...code to use the image!
}
非常感谢您的帮助、建议和工作片段