IOS _ 3rd library SDWebImage

Source: Internet
Author: User

IOS _ 3rd library SDWebImage

1. Add the downloaded source code package of the 3rd-party class library SDWebImage to the project.

2. Go to Build Phases of the project and add all. m files in the source code package to the project.

3. Import the built-in frameworks of the 3rd-party Class Library: MapKit. framework and ImageIO. framework.

4. Add the main header file "UIImageView + WebCache. h" of the 3rd-party class library"



Code snippet:

-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {static NSString * cellID = @ "Beyond"; UITableViewCell * cell = [tableView progress: cellID]; if (cell = nil) {// if the pool is not obtained, a new cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: cellID] is generated.} // set the unique content Status ** s = _ statuses in the cell. [IndexPath. row]; cell. textLabel. text = s. text; cell. detailTextLabel. text = s. user. screenName; cell. textLabel. numberOfLines = 0; // important ~ Using SDWebImage of the 3rd-party framework, the cache policy is: request upon failure, disk cache, and image download suspended when scrollView is rolled [cell. imageView setImageWithURL: [NSURL URLWithString: s. user. profileImageUrl] placeholderImage: [UIImage imageNamed: @ "avatar_default.png"] options: SDWebImageLowPriority | SDWebImageRefreshCached | cached]; // return cell ;}

Key code and Cache Policy:

Request again after failure: SDWebImageRetryFailed

Disk cache: SDWebImageRefreshCached

Pause downloading when scrollView is rolling. Image: SDWebImageLowPriority


[Cell. imageViewSetImageWithURL: [NSURLURLWithString: s. user. profileImageUrl]PlaceholderImage: [UIImageimageNamed: @ "avatar_default.png"]Options: SDWebImageLowPriority | SDWebImageRefreshCached | SDWebImageRetryFailed];


















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.