PhotoKit iOS8-使用"PHImageFileURLKey"检索图像 [英] PhotoKit iOS8 - Retrieve image using the "PHImageFileURLKey"

查看:269
本文介绍了PhotoKit iOS8-使用"PHImageFileURLKey"检索图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,我是否可以使用从"PHImageFileURLKey"返回的路径进入照片库并检索图像?

Is there anyway I can use the Path returned from the "PHImageFileURLKey" to go into the photo library and retrieve the image?

返回的路径采用以下格式:

The path returned is in this format:

"file:///var/mobile/Media/DCIM/102APPLE/IMG_2607.JPG"

我的计划是将此路径存储在数据库中,并在需要取回图像时使用它来获取图像.

My plan is to store this path in the database and use it to fetch the image when I need to get it back.

感谢您的帮助.谢谢!

推荐答案

我认为您从URL检索Photo Kit资产的解决方案是错误的.

I think your solution of retrieving Photo Kit asset from the URL is wrong.

这就是我要做的(假设您可以使用PHAsset):

Here is what I would do (supposing you have access to PHAsset):

存储localIdentifier:

Store the localIdentifier:

PHAsset *asset = /*Your asset */
NSString *localIdentifier = asset.localIdentifier;

//Now save this local identifier, or an array of them

当需要检索它们时,您只需执行以下操作:

When it is time to retrieve them you simply do:

PHFetchResult *savedAssets = [PHAsset fetchAssetsWithLocalIdentifiers:savedLocalIdentifiers options:nil];
[savedAssets enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) {
    //this gets called for every asset from its localIdentifier you saved
}];

如果您只能访问"PHImageFileURLKey",请忽略此答案.

If you only have access to "PHImageFileURLKey" then disregard this answer.

这篇关于PhotoKit iOS8-使用"PHImageFileURLKey"检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆