I have two possible widths for a string i want to display in a label in a table cell, and i need to compute the height so that the table cell's height is recorded correctly. however, no matter what I do for the constraining size i get the same height, which is incorrect in the case i want. The code i'm using:
CGFloat width = 300.0f;
NSString * value = @"LongText LongText LongText LongText LongText LongText";
CGSize contentSize = [value sizeWithFont: [UIFont systemFontOfSize: 14.0f]
constrainedToSize: CGSizeMake(width, CGFLOAT_MAX)
lineBreakMode: UILineBreakModeWordWrap];
When i inspect the contentSize variable, the width is 252 and the height is 36 which is expected. But if instead of 300.0f i plug in 222.0f into the width variable, the width is 189 but the height is still 36, and only the first 4 LongText words are displayed on 2 lines (the third line seems to be cut off somehow in the calculation). Does anyone know why this is happening?