Sdwebimage Simple to use

Source: Internet
Author: User

0, load the network picture, need to use the URL, so as long as the class provides a way to pass the URL, you can download pictures from the network,
For example, NSData can download images from the network and display them on ImageView:

Choose to load pictures with Sdwebimage!

1. the dependency framework

* Imageio.framework

* Mapkit.framework

2.UIImageView Download the desired header file for the image: Uiimageview+webcache.h

3. call the method to download the image

// URL is a picture path // placeholder is a placeholder picture (a picture that is temporarily displayed when a picture is being downloaded) // Options is the cache policy -(void) Setimagewithurl: (nsurl *) URL placeholderimage: (UIImage *) Placeholder-(void) Setimagewithurl: (nsurl *) URL placeholderimage: (UIImage *) placeholder options: ( sdwebimageoptions) options

4. Cache Policy-sdwebimageoptions

Tacit The hard disk \ Memory Cache is turned on . When you want to change the caching policy, you can specify the following parameters.

* sdwebimageretryfailed   download failed will try to download again * sdwebimagelowpriority   when Uiscrollview etc is scrolling, Delay Download Picture (place scrollview scroll card)* sdwebimagecachememoryonly only cached in memory, not cached on hard disk *  Sdwebimageprogressivedownload image will be displayed slowly at 1.1 (just like a picture on a Web page in a browser)* sdwebimagerefreshcached The disk cache to the system's own nsurlcache to handle, when the same URL corresponding to the picture changes often can use this strategy

General use of sdwebimageretryfailed | Sdwebimagelowpriority

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.