Q:

NSString boundingRectWithSize bounding not being respected

Does anyone know of a work around or what I am currently doing wrong here.
CGSize boundingSize = CGSizeMake(288, 9999);

CGRect boundingRect = [text boundingRectWithSize:boundingSize 
                                                 options:NSStringDrawingUsesLineFragmentOrigin
                                              attributes:[NSDictionary dictionaryWithObjectsAndKeys:theFont, NSFontAttributeName, nil]
                                                 context:nil];

When the code runs on iOS7 (both on the phone and sim) the size returned is 416.3 wide with a height of 15.5. Clearly the boundingRectWithSize is just being ignored. Has anyone else come across this and if so has anyone an idea on how to fix it or can someone point me to where I am going wrong. 

A:

As per the Apple documentation:

You can use this method to compute the space required to draw the
  string. The constraints you specify in the size parameter are a guide
  for the renderer for how to size the string. However, the actual
  bounding rectangle returned by this method can be larger than the
  constraints if additional space is needed to render the entire string.
  Typically, the renderer preserves the width constraint and adjusts the
  height constraint as needed.

If you specify a fixed font and too small a space, something has to give. In this case, it's the bounding space. I'm guessing you expected line wrapping. Does a width of 288 allow any reasonable wraps?

