How to use Sdwebimage

Source: Internet
Author: User

Function: Help us to deal with the network Picture processing frame specially

: Https://github.com/rs/SDWebImage

1 Setting up a picture
Contains a variety of features 1,sd_setimagewithurl get network picture 2,placeholderimage placeholder picture 3,progress  Download Progress   Usage:  nslog (@ "Download progress:%f", ( Double) receivedsize / expectedsize); 4, *image *error *imageurl, respectively, after the return of the picture, error and 5, sdimagecachetype cachetype  is an enumeration type, where the picture is stored in memory, disk, or no 6,sdwebimageoptions  enumeration type        Usage: sdwebimageoptions options = sdwebimageretryfailed | sdwebimagelowpriority     SDWebImageRetryFailed  download failed repeat download          common     SDWebImageLowPriority  Pause downloads When UI interacts     common      sdwebimagecachememoryonly  only save pictures in memory     SDWebImageProgressiveDownload  You can download refresh picture      SDWebImageRefreshCached  Refresh cache from top to bottom like a browser      sdwebimagehighpriority   High priority     SDWebImageDelayPlaceholder  no load for bitmap          &nbsP;   [cell.imageview sd_setimagewithurl: (nsurl *)                          Placeholderimage: (uiimage *)                                   options: (sdwebimageoptions)                        progress:^ (NSInteger receivedSize,  nsinteger expectedsize)  {        < #code #>                               } completed:^ (UIImage *image,                                             nserror  *error,                                  sdimagecachetype cachetype,                                              nsurl *imageurl)  {                 < #code #>     }];
2 Memory Processing

Because sdwebimgae belong to the entire project, not to a controller, so do not didreceivememorywarning in the controller to deal with memory problems, and add Applicationdidreceivememorywarning method in APPDELEGATE.M

-(void) applicationdidreceivememorywarning: (uiapplication *) application{sdwebimagemanager *MRG = [SDWebImageManager    Sharedmanager];    1, cancel the down operation [MRG Cancelall]; 2, clear the memory cache [Mrg.imagecache clearmemory];}
3 Other Features1, set periodic cleanup cache time
Set 100 days, default is 7 days [sdwebimagemanager sharedmanager].imagecache.maxcacheage = 100 * 24 * 60 * 60
2, set the maximum cache capacity
No default value, unit is unclear [sdwebimagemanager sharedmanager].imagecache.maxcachesize =;



How to use Sdwebimage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.