I've used this code to resize a UILabel
's frame height to fit dynamic text several times with success:
(...)
CGSize labelSize = [thelabel.text sizeWithFont:font constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
All was well until I started to build my apps using the iOS5 SDK.
For armv6 devices (iPhone3G/-), when building for debug, the label size is okay, but when building for release, the height value retrieved is the same as the width. I am running both of these builds on an actual device.
example with following log line:
NSLog(@"labelSize: %f %f", labelSize.width, labelSize.height);
output: iphone3G - debug >
Thu Nov 3 18:22:50 unknown appname[1071] : labelSize: 115.000000 19.000000
iphone3G - release >
Thu Nov 3 18:22:50 unknown appname[1071] : labelSize: 115.000000 115.000000
Can anyone help or provide me with another solution to adjusting UILabel
's height based on the text length?
I'm aware there are some similar questions about this method, but they do not address this particular issue.
I still haven't managed to understand the problem.
Although, replaced the UILabel resize method with an alternative way:
So, the issue persists, but, for the time being... I'm replacing the code occurrences for this approach.
If someone come up with a clue about what happened, please let me know. I'm guessing it+s a bug on sizeWithFont method... but is always easier to blame on the SDK when we can't understand... :)
Thank you all. Cheers.