#pragma mark-  UITableView
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
UIImage *img = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:_productDetailImageAry[indexPath.row]];
if (!img) {
img = [UIImage imageNamed:@"产品默认图"];
}
CGFloat height = img.size.height;
return (height/img.size.width)*CScreenWidth;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _productDetailImageAry.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MDSListImageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[self confirmCell:cell atIndexPath:indexPath];
return cell;
}
- (void)confirmCell:(MDSListImageCell *)cell atIndexPath:(NSIndexPath *)indexPath{
NSString *imgUrl = _productDetailImageAry[indexPath.row];
UIImage *cachedImg = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:imgUrl];
if (!cachedImg) {
[self downloadImage:imgUrl forIndexPath:indexPath];
}else{
cell.imageShow =cachedImg;
}
}
- (void)downloadImage:(NSString *)imageURL forIndexPath:(NSIndexPath *)indexPath{
__weak typeof(self) weakSelf = self;
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:SDIMAGE_URL(imageURL)
options:
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
}
completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
[[SDImageCache sharedImageCache] storeImage:image forKey:imageURL toDisk:YES];
[weakSelf performSelectorOnMainThread:@selector(reloadCellAtIndexPath:) withObject:indexPath waitUntilDone:NO]; }];
}
-(void)reloadCellAtIndexPath:(NSIndexPath *)indexPath {
[_listTableView reloadData];
}

iOS之UITableView加载网络图片cell自适应高度的更多相关文章

  1. iOS - UITableView加载网络图片 cell适应图片高度

    使用xib创建自定制cell   显示图片   创建一个继承UITableViewCell的类   勾选xib 如下是xib创建图 xib 向.h拖拽一个关联线 .h .m 2.代码创建(使用三方适配 ...

  2. ios UIImageView异步加载网络图片

    方法1:在UI线程中同步加载网络图片 UIImageView *headview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 4 ...

  3. iOS之WKWebView加载的网页自适应大小

    一,前言 有时候在WKWebView加载页面后会发现页面的字会很小, 这是因为原网页没有做手机屏幕尺寸的适配, 那么在后台不做调整的情况下我们移动端怎样来适配页面呢? 以下代码可以适配大小(原本不可以 ...

  4. ios UIImageView异步加载网络图片2

    //1. NSData dataWithContentsOfURL // [self.icon setImage:[UIImage imageWithData:[NSData dataWithCont ...

  5. iOS UItableview 镶嵌 collectionView ,cell 自适应高度动态布局

    最近在写这个功能,之前看到很多,可是需求一直没有涉及到,大致思路是有的,发现,网上的大部分都有缺陷和bug,我也是好无语啦啦啦,也不晓得是不是升级 了xcode,一样的代码,允许的效果都不一样,,,苦 ...

  6. 【iOS入门】UITableView加载图片

    学习带图片的列表 官方 LazyTableImages demo  http://download.csdn.net/detail/jlyidianyuan/5726749 分析源码是学习的好方法. ...

  7. UITableView加载几种不同的cell

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  8. 有关DTCoreText无法加载网络图片及应用问题

    至于DTCoreText是干嘛的,不清楚的同学自行网上脑补,这就不啰嗦了,只说一下其用法. 里面有三种控件供大家使用,DTAttributedTextView, DTAttributedLabel 和 ...

  9. UIImageView异步加载网络图片

    在iOS开发过程中,经常会遇到使用UIImageView展现来自网络的图片的情况,最简单的做法如下: 去下载https://github.com/rs/SDWebImage放进你的工程里,加入头文件# ...

随机推荐

  1. django 项目分析

    项目要点 一.功能制定 1.用户功能 #.登陆 #.权限组功能 2.数据展示功能 #.列表展示 #.详细信息展示 #.图标展示 3.资源管理功能 #远程管理 #对远程服务器上的进程具有 #开启 #关闭 ...

  2. 集群cluster概念

    集群是由两台或多台计算机(称为节点node或成员member)共同执行任务群集 集群方式: 存储集群  GFS共享存储 负载均衡  LB load balance 高可用     HA high av ...

  3. 关于soapui如何做安全测试

    1.首先安装soapui5.1.2 第一步:运行SoapUI-Pro-x32-5.1.2_576024.exe文件,按照步骤安装成功: 第二步:拷贝Protection-4.6.jar到soapui安 ...

  4. 数据库MySQL--子查询

    例子文件1:https://files.cnblogs.com/files/Vera-y/myemployees.zip 子查询:又称内查询,出现在其他语句中的select语句 主查询:又称外查询,内 ...

  5. css样式初始化代码总结

    编写css样式之前需要初始化css样式,总结如下: /* CSS Document */ html, body, div, span, object, iframe,h1, h2, h3, h4, h ...

  6. Open CV 环境配置

    { //https://github.com/zhmmmm/ANYTOOL-2.0.0.0.2Version/tree/master/OpenCVProject } /* //各个版本下载 https ...

  7. C++ 贪吃蛇二维

    #include <iostream> #include <conio.h> #include <windows.h> #include <time.h> ...

  8. csps模拟85表达式密码,电压机制,括号密码题解

    题面:https://www.cnblogs.com/Juve/articles/11733280.html 表达式密码: 是个水题... #include<iostream> #incl ...

  9. C/C++语言实现单链表(带头结点)

    彻底理解链表中为何使用二级指针或者一级指针的引用 数据结构之链表-链表实现及常用操作(C++篇) C语言实现单链表,主要功能为空链表创建,链表初始化(头插法),链表元素读取,按位置插入,(有序链表)按 ...

  10. 微信sdk 隐藏右上角菜单项

    wx.ready(function () { // 8.3 批量隐藏菜单项 wx.hideMenuItems({ menuList: [ 'menuItem:share:qq', //分享到QQ 'm ...