I\'ve a UITableView which contains a cell, which in turn contains a TTTextEditor (a Three20 control) which for all intents and purposes is a UITextView. I\'m using the TTTex
You need to set the contentSize
not the frame
. Calculate what the size SHOULD be, and then set it. This may require some calculation on your part. If you're dealing with text, then you may want to look at the method added to NSString
called sizeWithFont:constrainedToSize:lineBreakMode:
. Your frame, on the other hand, should always be the size of the viewable area, NOT the scrollable area.
EDIT: Note that for the initial layouts that are not changing at that moment, you will probably want to use the standard table delegate mechanism of - (CGFloat) tableView: (UITableView *) tableView heightForRowAtIndexPath: (NSIndexPath *) indexPath
, but when that needs to change dynamically like this situation, I think adjusting the content size is worth a try.
The first thing you need to do is to implement the table view delegate's -tableView:heightForRowAtIndexPath:
method. In this method you specify the height taken by each row in a table. If some rows in your table have a height which is different from others, then you need to implement this.
When this method is called for your text editor's row, just find the view's height and return it.
The second thing you need to do is to tell the table view to refresh itself whenever the editor's height change. I don't know how TTTextEditor works, but you can check that for a UITextView by implementing its delegate's -textViewDidChange:
method, for example. Once you know that the editor's height has changed just call the table view's -reloadData
method -- that should adjust the table's height appropriately.