Created
May 3, 2012 23:26
-
-
Save zbowling/2590376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HACK: Create an offscreen text view solely for calculating the height of table view cells | |
// containing text views. This bizarre hack is needed because: | |
// | |
// a.) UITextView is bizarre and uses WebKit instead of UIKit's methods for displaying strings, | |
// and NSString's sizeWithFont:constrainedToSize: does not calculate the height exactly as | |
// it does. (For instance, the height of strings with trailing whitespace are calculated | |
// differently, and UITextView some strange built-in padding and slightly | |
// different-than-usual line height that is annoyingly difficult to replicate, etc..., | |
// etc...). | |
// | |
// b.) If a UITextView has not been added to a view heirarchy, its contentSize property will... | |
// always... just be equal to the frame. In addition, desperately attempting to add it as a | |
// subview of another UIView, or even a UIWindow, which is also not a part of a parent's | |
// heirarchy does not seem to fix this, which means we have to sadly break separation of | |
// concerns and stuff it in here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment