如何使用 UIImagePicker 獲取圖像名稱?我得到了圖像名稱,但它只能在模擬器中工作,而不是在實際設備中

用戶8324856

我需要從照片庫中選擇圖像名稱。我正在使用 UIImagePicker 並且我得到了圖像名稱,但它只能在模擬器中工作,而不是在實際設備中。

桑茹克塔

請試試這個:在你的 UIImagePickerControllerDelegate 中:

   func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
    if let asset = info[UIImagePickerControllerPHAsset] as? PHAsset {
        let assetResources = PHAssetResource.assetResources(for: asset)

        print(assetResources.first!.originalFilename)
    }

    dismiss(animated: true, completion: nil)
}

它可能會幫助你。謝謝你。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档