Three20 framework, how to change default row height TTTableView?

白昼怎懂夜的黑 提交于 2019-12-05 23:13:55

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.

I answer myself here.

One solution is to override the initWithNibName method of the TTTableViewController as follows:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
    self.variableHeightRows = YES;

}
return self;

}

A second approach is to use TTTableViewDragRefreshDelegate as the delegate of your TTableViewController. This delegate sets variableHeightRows as true.

- (id<UITableViewDelegate>)createDelegate {
return [[[TTTableViewDragRefreshDelegate alloc] initWithController:self] autorelease];}

Solution for me:

I just moved those 2 lines into the viewDidLoad method; that worked for me!

- (void)viewDidLoad
{
    self.title = @"E-Mail";
    self.variableHeightRows = YES;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!