Image "moves" when varying heightForRowAtIndexPath in UITableViewCell.
- by Kalle
I have a table view with varying height, as defined in the heightForRowAtIndexPath. For some very odd reason, the image is "indented" to the right based on the height; if the height is low enough, the image is stuck to the left side of the cell, but as the height increases, the image for said cell is shifted rightward compared to other rows.
The result of this is a very poor looking list, with images floppily laid out in a zig-zag pattern depending on the height of each individual row.
The problem is revealed by this simple example:
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return (indexPath.row+1) * 50;
}
Each cell is set up (simplified) as a "Subtitle" style cell with:
// ...
cell.textLabel.text = @"foo";
cell.detailTextLabel.text = @"bar";
cell.imageView.backgroundColor = [UIColor redColor]; // for debugging; i have images with transparent bg
cell.imageView.image = anImageThatIs55x50pixelsBig;
return cell;
Any ideas? My head bleeds from the wall-love-affair.
Edit: uploaded a screen which displays this. The "image" is just a screenshot of a tiny area of the screen which makes it look a little weird, but you get the picture I'm sure: http://img28.imageshack.us/img28/549/screenshot20100311at172.png