views:

122

answers:

1

For some reason, when I am using the iPhone simulator, all of my text in my tableview cells displays correctly. However, when I publish to the device, the text inside of the cell is shifted up to almost outside of the bounds of the cell.

Any ideas as to why this would be happening on the device and not on the simulator?

A: 

This happened to me some time ago while inheriting from UITableViewCell. I don't know if this is your case or you are just using a standard UITableViewCell. I fixed it by overriding layoutSubviews and using the UITableViewCell's contentView as reference, here is a sample:

- (void)layoutSubviews {
    [super layoutSubviews];
    CGRect f = self.contentView.frame;

    [name setFrame:CGRectMake(10, f.origin.y+5, f.size.width - 10 - 90, 20)];
    [distance setFrame:CGRectMake(f.size.width - 80, f.origin.y+5, 80, 18)];
    [address setFrame:CGRectMake(10, f.origin.y + 25, f.size.width - 10, 15)];
    [extras setFrame:CGRectMake(10, f.origin.y + 41, f.size.width - 10, 15)];
}

hope it helps!

TehJabbit
I'm actually using just a UITableView. I am not using a custom cell or anything.
rson
ah, ok... If it helps, I think that contentView returned different rectangles on the simulator and on the device :S but I'm not sure.
TehJabbit
So I ended up just making a custom cell anyway. This way I can guarentee it working. Thanks for the tip!
rson