解决UITableView中image加载不同宽度尺寸图片的问题
来源:互联网 发布:资深java工程师招聘 编辑:程序博客网 时间:2024/05/16 06:26
如果你在寻找一个UITableView加载远程图片的方法,推荐一个第三方类库:SDWebImage。这个类库为你的工程提供了灵活的加载&缓存网络图片的方法,而且非常容易在工程中使用。
但当我开始使用时,当我加载不同分辨率的网络图片时,发现图片出现了不同宽度,很不美观,为了解决这个问题,我们需要对webimage中的不同宽度进行限制。
下面是一个简便有效的处理方法,自定义layoutSubviews:
1 - (void)layoutSubviews {2 [super layoutSubviews];3 self.imageView.frame = CGRectMake(5,5,40,32.5);4 float limgW = self.imageView.image.size.width;5 if(limgW > 0) {6 self.textLabel.frame = CGRectMake(55,self.textLabel.frame.origin.y,self.textLabel.frame.size.width,self.textLabel.frame.size.height);7 self.detailTextLabel.frame = CGRectMake(55,self.detailTextLabel.frame.origin.y,self.detailTextLabel.frame.size.width,self.detailTextLabel.frame.size.height);8 }9 }
1 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 2 { 3 static NSString *CellIdentifier = @"Cell"; 4 5 MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 6 if (cell == nil) { 7 cell = [[MyCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 8 } 9 10 // Configure the cell...11 [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]12 placeholderImage:[UIImage imageNamed:@"placeholder.png"]];13 return cell;14 }
- 解决UITableView中image加载不同宽度尺寸图片的问题
- html5根据不同的宽度加载不同的图片
- 网站前端设计中解决不同分辨率电脑测量尺寸不同的问题
- 根据设备不同,加载不同尺寸图片
- Android中解决加载过多图片出现的OutOfMemoryOutOfMemory问题 .
- J2ME中Image加载失败的问题
- universal image loader在listview/gridview中滚动时重复加载图片的问题及解决方法
- universal image loader在listview/gridview中滚动时重复加载图片的问题及解决方法
- universal image loader在listview/gridview中滚动时重复加载图片的问题及解决方法
- universal image loader在listview/gridview中滚动时重复加载图片的问题及解决方法
- 解决未知尺寸的图片撑破页面的问题
- uitableview 异步加载image
- iOS 解决xib加载UITableViewCell的宽度不适应问题
- IOS中UITableView异步加载图片的实现
- IOS中UITableView异步加载图片的实现
- iOS开发UITableView中ImageView图片的延迟加载思路
- 解决React Native的Image组件中不更新图片的问题
- UITableView中改变UIImage尺寸的方法
- Apache MPM两种方式讲解
- Centos 6编译安装apache&PHP&mysql
- WHY VERSION CONTROL IS IMPORTANT FOR SOLO DEVELOPERS
- __weak&__block&__unsafe__unretain
- iOS tip:让你的footTableView的UILabel居中
- 解决UITableView中image加载不同宽度尺寸图片的问题
- [ThirdParty]notnoop / java-apns
- [ThirdParty]Jedis
- word2007打开时总是弹出文件转换窗口【解决办法】
- 用户态和内核态的区别
- 做技术的出路
- Hadoop集群中hosts文件配置问题
- AS3 HTML标签使用
- Linux vim练级攻略