日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

多线程06-(sdwebimage 总结3)

發(fā)布時間:2024/1/18 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 多线程06-(sdwebimage 总结3) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2.SDWebImage 1> 常用方法 - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock;2> 內(nèi)存處理:當(dāng)app接收到內(nèi)存警告時 /*** 當(dāng)app接收到內(nèi)存警告*/ - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {SDWebImageManager *mgr = [SDWebImageManager sharedManager];// 1.取消正在下載的操作[mgr cancelAll];// 2.清除內(nèi)存緩存[mgr.imageCache clearMemory]; }3> SDWebImageOptions * SDWebImageRetryFailed : 下載失敗后,會自動重新下載 * SDWebImageLowPriority : 當(dāng)正在進(jìn)行UI交互時,自動暫停內(nèi)部的一些下載操作 * SDWebImageRetryFailed | SDWebImageLowPriority : 擁有上面2個功能 // // HMAppsViewController.m // 01-cell圖片下載(了解) // // Created by apple on 14-9-18. // Copyright (c) 2014年 heima. All rights reserved. //#import "HMAppsViewController.h" #import "HMApp.h" #import "UIImageView+WebCache.h"@interface HMAppsViewController () /*** 所有的應(yīng)用數(shù)據(jù)*/ @property (nonatomic, strong) NSMutableArray *apps; @end@implementation HMAppsViewController#pragma mark - 懶加載 - (NSMutableArray *)apps {if (!_apps) {// 1.加載plistNSString *file = [[NSBundle mainBundle] pathForResource:@"apps" ofType:@"plist"];NSArray *dictArray = [NSArray arrayWithContentsOfFile:file];// 2.字典 --> 模型NSMutableArray *appArray = [NSMutableArray array];for (NSDictionary *dict in dictArray) {HMApp *app = [HMApp appWithDict:dict];[appArray addObject:app];}// 3.賦值self.apps = appArray; // _apps = appArray;}return _apps; }#pragma mark - 初始化方法 - (void)viewDidLoad {[super viewDidLoad];}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];}#pragma mark - Table view data source - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return self.apps.count; }- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {static NSString *ID = @"app";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];if (!cell) {cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];}// 取出模型HMApp *app = self.apps[indexPath.row];// 設(shè)置基本信息cell.textLabel.text = app.name;cell.detailTextLabel.text = app.download;// 下載圖片NSURL *url = [NSURL URLWithString:app.icon];UIImage *placeholder = [UIImage imageNamed:@"placeholder"]; // [cell.imageView sd_setImageWithURL:url placeholderImage:placeholder];// [cell.imageView sd_setImageWithURL:url placeholderImage:placeholder completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { // NSLog(@"----圖片加載完畢---%@", image); // }];SDWebImageOptions options = SDWebImageRetryFailed | SDWebImageLowPriority;[cell.imageView sd_setImageWithURL:url placeholderImage:placeholder options:options progress:^(NSInteger receivedSize, NSInteger expectedSize) { // 這個block可能會被調(diào)用多次NSLog(@"下載進(jìn)度:%f", (double)receivedSize / expectedSize);} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {NSLog(@"----圖片加載完畢---%@", image);}];return cell; } @end

總結(jié)

以上是生活随笔為你收集整理的多线程06-(sdwebimage 总结3)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。