我需要從照片庫中選擇圖像名稱。我正在使用 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] 删除。
我来说两句