views:

374

answers:

2

Hi,

I have a custom table cell in an iPhone 3.x app to show basketball player data, including a picture. Here's my code from the table controller:

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;

Here's what it looks like in the iPhone SDK 3.0 simulator:

3.0 simulator screenshot

Here's what it looks like in the iPhone SDK 3.1.3 simulator:

3.1.3 simulator screenshot

So I have two problems:

  1. In both versions, the image view starts at position (0,0) in the table cell, even though I set the frame to start at (14,0).
  2. In the 3.0 simulator (and 3.0 device), the image is not shrunk down correctly, even though I set the image view content mode to "UIViewContentModeScaleAspectFit". But the same code works fine in the 3.1.3 simulator / device.

Who can help me with either of these two problems?

A: 

You could try creating your own UIImageView and adding it as a subview to table cell

Marichka
A: 

I found the answer on the Apple forums: Using "0" as the tag number for the image view screwed things up; just changing it to "5" made both problems (image not scaled, wrong position) go away.

Karsten Silz