views:

87

answers:

2

I've seen at least one application that uses a grouped UITableView with a cell containing paragraphs of text, and the cell is taller or shorter based on the length of the text, but I don't quite get how this is done.

How does one, given a variable width font, figure out how high a UITextField or something needs to be in order to display all of the text contained in it without reducing the point size of the font?

+1  A: 

See Apple's documentation about NSString additions for the iPhone to read about which methods to use to calculate these metrics.

Alex Reynolds
Thanks. I'm still not used to the whole Category pattern used in Objective-C. I understand how it works and what the point is, but I'm just so used to being able to look up the docs for `NSString` and find ALL of the supported methods. So I keep finding methods like `awakeFromNib` that are defined as NSObject methods, and I'm basically like "WTF? I thought I read the docs on NSObject already?" I wish there were a good way I could look up all of the methods for a given class like NSString defined by anything that defines a category in say Cocoa Touch or something.
Nimrod
Apple added a few category additions for `NSString` and `UITableView` to help make them easier to use on the iPhone. You can also make your own category additions, to make these and other classes more useful. Categories are a really awesome design pattern for Objective-C and I definitely recommend learning about them. That said, the one thing I have learned from my limited amount of time working with Cocoa is that the best docs are the header files themselves, as opposed to Apple's official documentation.
Alex Reynolds
+1  A: 

http://stackoverflow.com/questions/129502

Ian Henry
Thanks. I searched around but couldn't seem to come up with the right language for the search or something :(
Nimrod