cell.imageView.image的大小 会随着Cell的高度而变化,不同的图片显示的也不一样,在网上找了几种方法,简单方便的是下面这种:

UIImage *icon = [UIImage imageWithName:@"xxxxx"];
CGSize itemSize = CGSizeMake(30, 30);
UIGraphicsBeginImageContextWithOptions(itemSize, NO,0.0);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[icon drawInRect:imageRect];
 
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

另外还有其它方法没有成功:设置cell.imageView.contentMode的属性,
还有一种是网上转载的比较多的一种,由于不是自定义的cell,没用到此方法 :

重定义一个uitableviewcell,它自动生成的代码不需要动,只要在.m文件中再加上下面的代码即可:

(具体可参看:http://blog.csdn.net/zhangjie1989/article/details/7550990)

- (void)layoutSubviews {

[superlayoutSubviews];

self.imageView.bounds =CGRectMake(0,0,44,44);

self.imageView.frame =CGRectMake(0,0,44,44);

self.imageView.contentMode =UIViewContentModeScaleAspectFit;

CGRect tmpFrame = self.textLabel.frame;

tmpFrame.origin.x = 46;

self.textLabel.frame = tmpFrame;

tmpFrame = self.detailTextLabel.frame;

tmpFrame.origin.x = 46;

self.detailTextLabel.frame = tmpFrame;

}

还有一种最直接 的方法 就是自定义一个cell。

最新文章

  1. 记一次Redis被攻击的事件
  2. 关于在用curl函数post网页数据时,遇上表单提交 type为submit 类型而且没有name和id时可能遇到的问题及其解决方法
  3. Redis学习笔记1-Redis的介绍和认识
  4. HDU 4314 Save the dwarfs (DP) ---转载
  5. BZOJ2159 : Crash 的文明世界
  6. OpenWRT 路由配置技巧
  7. android圆角View实现及不同版本这间的兼容
  8. C#中两个时间的比较
  9. php_cawler_html嵌套标签清洗
  10. Python——Python+Pydev出现SyntaxError: Non-UTF-8 code
  11. django-celery配置
  12. Ionic3多个自定义过滤器--管道(pipe)
  13. 201901<<叶武滨时间管理100讲>>
  14. IPv6地址测试宏
  15. Java 深复制和浅复制
  16. ARM Linux Oops使用小结(转)
  17. 《DSP using MATLAB》Problem5.23
  18. springboot 设置 session 过期时间
  19. 虚拟机中安装Ubuntu 16.04
  20. How To Open An URL In Android’s Web Browser

热门文章

  1. 【Linux CentOS 在虚拟机中XShell出现: (port 22): Connection failed.】
  2. EPiServer 简单项目总结
  3. AOP概念
  4. wikioi1450 xth的旅行
  5. poj 1157 LITTLE SHOP_简单dp
  6. awk(流程控制、内置变量、内置函数、数组)
  7. (转)flash的Socket通讯沙箱和安全策略问题
  8. sctf pwn400
  9. SecureCRT中文显示乱码的解决方法
  10. JavaScript跨域深入研究与解决办法(转)