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];