I have TTViewController include a TTTableView inside and init TTTableView like below:
- (void)loadView{
appTableView = [[TTTableView alloc] initWithFrame:CGRectMake(10, 20, self.view.width - 20, (self.view.height - 44 - 49)/2 - 40)];
appTableView.backgroundColor = [UIColor clearColor];
appTableView.delegate = self;
appTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:appTableView];
}
and in
- (void)requestDidFinishLoad:(TTURLRequest*)request {
appTableView.dataSource = [TTListDataSource dataSourceWithObjects:
[CustomTTTableSubtitleItem itemWithTitle:result.resourceName text:textCombine ],nil];
}
I’ve coded this:
- (Class)tableView:(UITableView*)tableView cellClassForObject:(id) object {
if ([object isKindOfClass:[CustomTTTableSubtitleItem class]]) {
NSLog(@"here");
return [CustomTTTableSubtitleItemCell class];
}
else {
return [self tableView:tableView cellClassForObject:object];
}
}
and of course I added protocol
@interface TestController : TTViewController<TTTableViewDelegate,TTTableViewDataSource>
but seems -(Class)tableView:(UITableView*)tableView cellClassForObject:(id) object not be called… anything I missed?
the
- (Class)tableView:(UITableView*)tableView cellClassForObject:(id) objectis a TTTableViewDataSource function, so you will have to extend the TTListDataSource into your own data source class, and override this function there and not under TTViewController.In your TTViewController, create the custom data source:
and in your custom TTTableViewDataSource have your
- (Class)tableView:(UITableView*)tableView cellClassForObject:(id) objectcustom function