带有PHAssets的SDWebImage [英] SDWebImage with PHAssets

查看:162
本文介绍了带有PHAssets的SDWebImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我从数据库加载大量图像并在我的库中显示它们,我之前做的是我从PHAsset获取照片网址(本地标识符)然后使用PHCacheManager访问图像,但是它会减慢我的滚动速度,并在更新新单元格中的图像时显示滞后。我试图通过将url传递给sd_setImageWithURL:方法来使用SDWebImage,但是我发现该URL实际上是该方法不支持的本地标识符。我们是否有其他机制可以使用标识符使用SDWebImage或任何其他框架更快地加载图像。

i have an application where i am loading large amount of images from database and showing them in my gallery, what i was doing earlier is i was getting photo url (local identifier) from PHAsset and then accessing the image using PHCacheManager, but it slows down my scrolling and also shows lags while updating images in new cell. I was trying to use SDWebImage here by passing the url to the sd_setImageWithURL: method, however i found out that the URL is actually a local identifier which is not supported by the method. Do we have other mechanism where i can use the identifier to load the images faster using SDWebImage or any other framework.

这是我的代码:

NSURL *photoURL = [NSURL URLWithString:photoPath];
[imageView sd_setImageWithURL:photoURL placeholderImage:defaultImage];




photoPath是我的资产要加载的当前图像的路径

photoPath is the path to my asset "current image to be loaded"

我得到的网址类似于:


73F05642-CAE6-49BE-879B-9B00BF15391F / L0 / 001

73F05642-CAE6-49BE-879B-9B00BF15391F/L0/001

请询问是否需要更多信息,我是新的到iOS和所有这些东西。在此先感谢:)

Please ask if more information is needed, i am new to iOS and all this stuff. Thanks in advance :)

推荐答案

现在已经很晚了,但我发布它会对其他人有所帮助。

it's late , but i am posting it so that it will be helpful for others .

SDWebImageManager * manager = [SDWebImageManager sharedManager];

[manager downloadImageWithURL:[NSURL URLWithString:localIdentifier] options:SDWebImageHighPriority targetLocalAssetSize:CGSizeMake(150, 150) progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {

    if (image) {

        imageview.image = image;
    }

}];

这篇关于带有PHAssets的SDWebImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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