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.
Had the same issue.
If you follow the link supplied by vfonseca, you arrive at: Is there a way to compile for ARM rather than Thumb in Xcode 4?
And the selected answer tells you how to add the correct compiler flags to prevent this. Alternatively upgrade to Xcode 4.3 which has fixed this bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With