Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three20 framework, how to change default row height TTTableView?

I am using a TTListDataSource to populate a TTTableViewController.

This is the code I am using to populate the TTListDatSource items array:

NSString *text = [NSString stringWithFormat:@"<b>%@</b><br/>%@", someObject.title, someObject.text];
TTStyledText *styledText = [TTStyledText textFromXHTML:text lineBreaks:YES URLs:YES];
[items addObject:[TTTableStyledTextItem itemWithText:styledText]];

I would like to change the default row height the TTTableView is using, currently 2 lines height.

any ideas how can I do that?

I've tried using these properties in few parts of my code with no luck:

TTTableViewController.variableHeightRows = YES; 
TTStyledText.setNeedsLayout;
TTStyledText sizeToFit;
like image 963
yeforriak Avatar asked May 29 '26 12:05

yeforriak


1 Answers

If you use variableHeightRows then in your table cell classes you need to implement:

+ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object;

Beware that using variableHeightRows will cause the framework to go through your entire datasource calling this method to get the overall height of the table. If all your rows are the same height then in your TTTableViewController subclass in loadView your should set the rowHeight property of the tableView.

like image 156
lyonanderson Avatar answered May 31 '26 15:05

lyonanderson