iPhone: image in table cell - wrong position & not scaled correctly in iPhone 3.0

Posted by Karsten Silz on Stack Overflow See other posts from Stack Overflow or by Karsten Silz
Published on 2010-04-27T14:26:37Z Indexed on 2010/05/01 11:47 UTC
Read the original article Hit count: 1086

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?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk