加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – 不推荐使用ALAsset – 使用Photos Framework中的PHAsse

发布时间:2020-12-14 04:44:13 所属栏目:百科 来源:网络整理
导读:我正在使用检索图像 func imagePickerController(picker: UIImagePickerController,didFinishPickingMediaWithInfo info: [String : AnyObject]) } let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage} 我可以检索图像,也可以使用图
我正在使用检索图像

func imagePickerController(picker: UIImagePickerController,didFinishPickingMediaWithInfo info: [String : AnyObject]) }
      let chosenImage = info[UIImagePickerControllerOriginalImage] as! UIImage
}

我可以检索图像,也可以使用图像输入按钮背景或我想要的任何其他内容,但我似乎无法检索照片的元数据.现在,关于使用ALAssets及其技术用于图像数据的互联网上的各种其他位置有很多话题,但是,BUT,ALAssets最近被弃用了.由于我的图像不是用户刚拍摄的图像,而是从相机胶卷中选择的图像,我无法使用:

让metadata = info [UIImagePickerControllerMediaMetaData]为!的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))

}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读