问题描述
我有一个应用程序,我从数据库加载大量图像并在我的库中显示它们,我之前做的是我从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];
我得到的网址类似于:
请询问是否需要更多信息,我是新的到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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!