Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As anyone who has puzzled this out learns, the method is inappropriately named and rather inconsistent with what you'd expect (that's a violation of good API design, but as any seasoned dev knows: Apple's API is not well designed, sorry guys). Worth reading: <a href="http://lcsd05.cs.tamu.edu/slides/keynote.pdf" rel="noreferrer">Josh Bloch's presentation</a> on good API design.</p> <p>I'd posit that they should rename it (if it must be kept) and make this one useful, such that you don't end up using the common practice of passing in a <code>CGSize</code> with a size you know is much too large.</p> <pre><code>[someString sizeWithFont:yourFont constrainedToSize:CGSizeMake(maxWidthYouSpecify, self.frame.size.height) lineBreakMode:UILineBreakModeWordWrap]; </code></pre> <p>Alternately this would work just as well:</p> <pre><code>[someString sizeWithFont:yourFont constrainedToSize:CGSizeMake(maxWidthYouSpecify, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap]; </code></pre> <p>This is, arguably, how the function should work. (FWIW, <code>CGFLOAT_MAX</code> is defined in <a href="https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGGeometry/Reference/reference.html" rel="noreferrer">CGGeometry</a>)</p> <p>An aside, but rather important: all Core Graphics deal in points not pixels.</p> <blockquote> <p>One point does not necessarily correspond to one pixel on the screen.</p> </blockquote> <p>That's an important distinction and one you need to understand when dealing with different resolutions (iPhone 3GS vs 4 vs iPad, etc). See Apple's <a href="https://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GraphicsDrawingOverview/GraphicsDrawingOverview.html" rel="noreferrer">docs</a> and Command+F for "Points vs Pixels".</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload