第三方加载图片
2015-09-01 19:34
260 查看
#import "TableViewCell.h" #import "ImageModal.h" // 下载图片(MRC) #import "UIImageView+WebCache.h" @implementation TableViewCell #pragma mark - 给cell赋值方法 - (void)setCellModal:(ImageModal *)modal { // 第三方 可以付动态图 [self.pictureImageView sd_setImageWithURL:[NSURL URLWithString:modal.imageUrlString] placeholderImage:[UIImage imageNamed:@"5.png"]]; } cellForRowAtIndexPath // cellForRowAtIndexPath - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"TableViewCell"; TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; ImageModal *modal = self.dataArray[indexPath.row]; [cell setCellModal:modal]; cell.titleLabel.text = modal.title; return cell; }
利用第三方 MBProgressHUD
#pragma mark - 网络请求 - (void)loadDataFromNetWork { NSString *urlString = @"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/activitylist.php"; // 显示进度条(解析数据前) [MBProgressHUD showHUDAddedTo:self.mainTableView animated:YES]; // 解析数据(第三方) JSONAnalysis *json = [[JSONAnalysis alloc] initWithGETRequest:urlString]; [json didFinishUsingBlock:^(id jsonObject) { // 解析 NSArray *array = jsonObject[@"events"]; for (NSDictionary *dict in array) { ImageModal *modal = [[ImageModal alloc] init]; [modal setValuesForKeysWithDictionary:dict]; modal.imageUrlString = dict[@"image"]; [self.dataArray addObject:modal]; // 隐藏进度条(解析完数据) [MBProgressHUD hideHUDForView:self.mainTableView animated:YES]; } // 刷新cell(解析完数据) [self.mainTableView reloadData]; }]; } 清除缓存 // 清除缓存 [[SDImageCache sharedImageCache] cleanDisk]; [[SDImageCache sharedImageCache] clearDisk];
相关文章推荐
- 获取本机外网ip获取位置
- 散列操作的基本例程(1)
- react-native试玩(6)-日期选择控件
- hdu 2002 计算球体积
- oracle 学习sql
- OC03_继承
- leetcode 201:Bitwise AND of Numbers Range
- 计算机为什么要用补码
- Java核心API -- 14(Socket)
- 2015多校联合第二场5308I Wanna Become A 24-Point Master
- 第三方加载图片
- Reactor Pattern Explained
- 多线程相关
- anjs 分词器初步使用
- gridview控件
- 期望时间为线性时间的选择算法(C++)
- poj 2002 Squares
- Chisel-LLDB命令插件,让调试更Easy
- flume日志收集系统搭建
- [持续更新]HTML5学习笔记(三)