代码之家  ›  专栏  ›  技术社区  ›  Karsten Silz

iphone:表格单元格中的图像-位置错误,在iphone 3.0中缩放不正确

  •  0
  • Karsten Silz  · 技术社区  · 16 年前

    我在iPhone3.x应用程序中有一个自定义的表格单元格,用于显示篮球运动员的数据,包括图片。这是我的表控制器代码:

    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

    所以我有两个问题:

    1. 在这两个版本中,图像视图都从表单元格中的位置(0,0)开始,即使我将帧设置为从(14,0)开始。
    2. 在3.0模拟器(和3.0设备)中,图像没有正确缩小,即使我将图像视图内容模式设置为“uiviewcontentmodescalespectfit”。但同样的代码在3.1.3模拟器/设备中运行良好。

    谁能帮我解决这两个问题?

    2 回复  |  直到 16 年前
        1
  •  0
  •   Marichka    16 年前

    您可以尝试创建自己的uiimageview并将其作为子视图添加到表单元格中

        2
  •  0
  •   Karsten Silz    16 年前

    我在 Apple forums :使用“0”作为图像视图的标记号会使事情变得一团糟;将其更改为“5”会使这两个问题(图像未缩放、位置错误)消失。