SDWebImage with PHAssets

一笑奈何 提交于 2019-12-25 04:49:35

问题


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.

This is my code:

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

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

i am getting the url something like:

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

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


回答1:


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;
    }

}];


来源:https://stackoverflow.com/questions/28965172/sdwebimage-with-phassets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!