0

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?

1 Answer 1

0

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!

3
  • I'm actually using just a UITableView. I am not using a custom cell or anything.
    – rson
    Nov 20, 2009 at 15:03
  • 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
    Nov 20, 2009 at 15:23
  • So I ended up just making a custom cell anyway. This way I can guarentee it working. Thanks for the tip!
    – rson
    Nov 20, 2009 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.