sdwebimage

Explain __weak and __strong usage reasons in SDWebImage code

て烟熏妆下的殇ゞ 提交于 2019-11-30 13:29:19
问题 I think I understand strong and weak keywords well, but I don't understand how it's used in the code below. This code is from SDWebImage by Olivier Poitrey available on github. I understand strong and weak keywords as is described here: Explanation of strong and weak storage in iOS5 The code below uses __weak and __strong keywords in a way that is curious to me. It is not a child-parent relationship or delegate pattern as I am used to seeing weak used. However, I'm sure that this is a pattern

SDWebImage clearing cache

笑着哭i 提交于 2019-11-30 06:28:37
问题 I'm displaying a list of icons downloaded from the web with text in a table view. The icons can be changed on server side and I need to replace them as soon as new icons are getting available. I try using the following code: [imgView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"table_avatar_icon"] options:SDWebImageCacheMemoryOnly]; And call [[SDImageCache sharedImageCache] clearMemory]; In my refresh callback, but it does not purge the contents of the cache. More to it, even if

How to use completion block using SDWebImage in Swift 3.0?

Deadly 提交于 2019-11-30 03:35:47
问题 Am using SDWebImage to download image. I want to do further operation if image is downloaded successfully. cell.appIcon.sd_setImage(with: url, placeholderImage: UIImage.init(named: "App-Default"), completed: {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType, imageURL: URL!) -> Void in // Perform operation. }) But I am getting error: Cannot convert value of type '(UIImage!, NSError!, SDImageCacheType, URL!) -> Void' to expected argument type 'SDExternalCompletionBlock?' 回答1:

How to show an activity indicator in SDWebImage

孤人 提交于 2019-11-30 02:00:43
Currently i am integrating SDWebImage in my project by following below things 1)#import "UIButton+WebCache.h" 2)[button setImageWithURL:url placeholderImage:[UIImage imageNamed:@"no_photo.png"]]; So it will show the list of image present in URL above the respective buttons. But Now i want to show an activity indicator above button when the image is getting downloaded ,So how can i do this? Works like a charm for me : Swift 3: imgView.setShowActivityIndicator(true) imgView.setIndicatorStyle(.gray) imgView.sd_setImage(with: URL(string: urlString), placeholderImage: UIImage(named: "placeholder"))

Build fail when using SDWebImage

筅森魡賤 提交于 2019-11-30 01:15:34
问题 I am trying to use the classes of SDWebImage in my project. I've added the classes to my project and when I try to build it I get 7 errors: Undefined symbols for architecture i386: "_OBJC_CLASS_$_MKAnnotationView", referenced from: l_OBJC_$_CATEGORY_MKAnnotationView_$_WebCache in MKAnnotationView+WebCache.o "_CGImageSourceCreateIncremental", referenced from: -[SDWebImageDownloader connection:didReceiveData:] in SDWebImageDownloader.o "_CGImageSourceUpdateData", referenced from: -

SDWebImage Download image and store to cache for key

浪尽此生 提交于 2019-11-29 23:05:52
Hello I am using the SDWebImage framework in a project and I want to download and cache images, but I think my code is storing an image in the cache twice? Is there any way to store the image in the cache by a key only once? Here is my code. SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadWithURL:[NSURL URLWithString:url] options:0 progress:^(NSUInteger receivedSize, long long expectedSize) { } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) { if(image){ NSString *localKey = [NSString stringWithFormat:@"Item-%d", i]; [

How to cache image and scale it correctly?

半世苍凉 提交于 2019-11-29 17:34:12
I am currently using SDWebimage and calling it like so, not sure if it is caching or how I can check it? Also, how do I scale it accordingly without it looking stretched. The picture is originally 512 x 512 and I want to scale it down. I saw this post was not sure if I should be using this method? Resize UICollectionView cells after image inside has been downloaded //setting up each cell -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { CollectionGridCell *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:

How to get filesystem path to image cached with SDWebImage (iOS)

好久不见. 提交于 2019-11-29 16:15:47
I'm using SDWebImage for image caching at UICollectionView in my iOS app. Everything is fine, however, when user scrolls fast over the collection view there is always little pause before placeholder is replaced with the cached image. I believe this is due to cache checks. For better user experience I would like cells to show the proper image instead of placeholder once an image is actually cached. This would be easy if I could get local (device) filesystem's path of the cached image and store it at the Show instance, and use it (if exists) instead of my placeholder. There is the possibility to