Uneven text on table cells on iPhone

For some reason, when I use the iPhone simulator, all my text in the cells of the table is displayed correctly. However, when I publish on the device, the text inside the cell shifts almost to the limits of the cell borders.

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

0
source share
1 answer

This happened to me a while ago, inheriting from a UITableViewCell. I do not know if this is your business or you are using the standard UITableViewCell. I fixed it by overriding layoutSubviews and using the UITableViewCell contentView as a link, here is an example:

- (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)];
}

, !

0

All Articles