imp*_*7vx 5 metadata uiimagepickercontroller alassetslibrary swift phphotolibrary
我正在使用检索图像
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) }
let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
}
Run Code Online (Sandbox Code Playgroud)
我可以检索图像,也可以使用图像输入按钮背景或我想要的任何其他内容,但我似乎无法检索照片的元数据.现在,关于使用的互联网上的各种其他位置ALAssets以及它们的图像数据技术的讨论很多,但是,ALAssets最近已经弃用了它们.由于我的图像不是用户刚拍摄的图像,而是从相机胶卷中选择的图像,我无法使用:
let metadata = info[UIImagePickerControllerMediaMetaData] as! NSDictionary
所以,如果有人能够指出我如何获取用户从他们的相机胶卷中选择的图像元数据的正确方向,而不使用ALAssets,那将非常感谢!谢谢!
如果你想从相机胶卷获取图像,那么这将有所帮助:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
let imageUrl = info["UIImagePickerControllerReferenceURL"]
let asset = PHAsset.fetchAssetsWithALAssetURLs([imageUrl], options: nil).firstObject as! PHAsset
print("location: " + String(asset.location))
print("Creation Date: " + String(asset.creationDate))
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4385 次 |
| 最近记录: |