我在iPhone 3.x应用程序中有一个自定义表格单元格来显示篮球运动员数据,包括图片。下面是来自台控制器我的代码:iPhone:表格单元格中的图片 - 错误的位置并且在iPhone 3.0中未正确缩放
UIImageView *theImage = (UIImageView *) [cell viewWithTag:0];
theImage.image = [manager getSmallImageForPlayer: data.number];
theImage.frame = CGRectMake(14, 0, 30, 44);
theImage.clipsToBounds = YES;
theImage.contentMode = UIViewContentModeScaleAspectFit;
theImage.autoresizingMask = UIViewAutoresizingFlexibleHeight && UIViewAutoresizingFlexibleWidth;
theImage.autoresizesSubviews = YES;
这里就是它看起来像在iPhone SDK 3.0模拟器:
3.0 simulator screenshot http://img96.imageshack.us/img96/9550/imageintablecell30.png
下面是它看起来像在iPhone SDK 3.1.3模拟器:
3.1.3 simulator screenshot http://img185.imageshack.us/img185/9269/imageintablecell313.png
所以,我有两个问题:
- 在这两个版本中,图像视图都从表格单元的位置(0,0)开始,即使我将帧设置为从(14,0)开始。
- 在3.0模拟器(和3.0设备)中,即使将图像视图内容模式设置为“UIViewContentModeScaleAspectFit”,图像也不会正确收缩。但是相同的代码在3.1.3模拟器/设备中工作正常。
谁能帮我解决这两个问题?
如何将'UIImageView'添加到'UITableViewCell'? – 2010-04-27 14:54:20
我不这样做,它已经在自定义表单元格MIB中从中读取“viewWithTag”,然后设置其属性。 – 2010-04-27 19:04:37