Ios_ 3rd party Class library sdwebimage simple to use

Source: Internet
Author: User

1, will download the good 3rd party class Library sdwebimage source Package Join the project

2, enter the project Build phases, the source package inside all the. m files are added to the project

3, import the framework of the two systems that the 3rd party class library relies on:mapkit.framework, Imageio.framework

4, add the 3rd party class Library's main header file "uiimageview+webcache.h"



Code uses fragments:

-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{static NSString *cellid = @ "B    Eyond ";    UITableViewCell *cell = [TableView dequeuereusablecellwithidentifier:cellid]; if (cell = = nil) {//If the pool is not picked up, regenerate a cell cell = [[UITableViewCell alloc]initwithstyle:uitableviewcellstyles    Ubtitle Reuseidentifier:cellid];    }//Set unique content in cell Status *s = _statuses[indexpath.row];    Cell.textLabel.text = S.text;    Cell.detailTextLabel.text = S.user.screenname;    Cell.textLabel.numberOfLines = 0; Important ~ Use 3rd party framework Sdwebimage, cache policy: failed re-request, disk cache, ScrollView pause download picture when scrolling [Cell.imageview setimagewithurl:[nsurl urlwithstring: S.user.profileimageurl] placeholderimage:[uiimage imagenamed:@ "Avatar_default.png"] options:SDWebImageLowPriority | sdwebimagerefreshcached |    Sdwebimageretryfailed]; return cell return cell;} 

Key Code, Caching Policies :

failed re-request :sdwebimageretryfailed

disk cache :sdwebimagerefreshcached

ScrollView Scrolling When you pause download 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.