-sizeWithFont Functions Differently on Device
Posted
by LucasTizma
on Stack Overflow
See other posts from Stack Overflow
or by LucasTizma
Published on 2010-04-13T19:14:32Z
Indexed on
2010/04/13
21:53 UTC
Read the original article
Hit count: 339
So I am seemingly encountering some strange behavior when using NSString
's -sizeWithFont
family of method calls depending on whether or not I'm invoking it on the iPhone Simulator or an actual device.
Simply enough, when the receiver of the -sizeWithFont
method call is nil
, the resulting CGSize
passed back on the Simulator is {0, 0}
. However, on the device, it is the size of the bounding rectangle I specified in the method call. See the following log statements:
Simulator:
someString: (null)
someStringSize: {0, 0}
Device:
someString: (null)
someStringSize: {185, 3.40282e+38}
The behavior on the Simulator is what I would expect. Not that this issue is difficult to circumvent, but 1) I'm a little confused why this family of functions would behave differently on the Simulator and an actual device, and 2) why does calling a method on a nil
receiving return a particular result?
Thanks for any pointers or insight you guys can provide!
EDIT: I suppose I should mention that I'm building against the 3.1 SDK.
© Stack Overflow or respective owner