UPDATE: iOS 4 is a major player. If you’re running the iOS 4 sim, the labels will return 0.00 for the size, since it never loaded… this changes my final question to be: “How do you find the font size in iOS 4, if the Xib is loading a different font? Or… would it be better to load a working font for both, grab the size, then change it to be the newer one if iOS 5, just flipping the test?”
The latter seems obvious, but isn’t ideal for the reason that, the designer goes into the Xib and the new font is thinner, thus we have to change the size to be smaller for normal Helvetica (for iOS 4). If visually, the designer and I look at the wrong font when designing it, it’s just not ideal.
Perhaps I figured this one out, but I’m hoping an iOS wizard can answer this xib-becomes-0 initial testing on xib load issue, if it is possible.
—– end update —–
I’m trying to grab the currently set font pointSize from my outlets and am having a really tough time.
The problem: iOS 4 doesn’t support the font I’m using. iOS 5 does.
The solution: Call a function that gets the current iOS level, and if 5, return the very same label and use its font type. If iOS 4, set it to Helvetica and try to grab its size (set in the xib).
Grabbing the size is impossible, it always returns 0.00 (except for some cases, about to determine that, but…) the cause is not from lazy loading. I just called the same function (the change font one) after 1 second delay upon loading of the view.
The results:
NSLogging the labelName.font.pointSize before the “get font for XX” function prints 0.00, doing it after prints the sizes.
The weird part: While I can’t manually find it, regardless of if I use xHeight, pointSize, or lineHeight (frame.size.height is too large, otherwise would do that), if I simply return the font for iOS 5, it looks fine, as if, somehow-somewhere it finds the right value. I’m wishfully thinking that might not be private, but haven’t found that.
Problem can’t be lazy loading making stuff nil, ’cause the second delay’s way more than time needed to load the labels (and they’re visible).
Now to reboot, thanks to the unfixable boostrap thing.
Thanks for any help!
I’m not new to iOS, this is puzzling me a bit
I have not found any solution since asking.
I believe the answer is:
iOS 4 simply does not create the font or rather:
Previous iOS Versions do not create label’s texts if the font does not exist on that platform.
I just know this isn’t documented because it’s in a WWDC video, like MKMapKit mapRect defs