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) object
is 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:
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)requestDidFinishLoad:(TTURLRequest*)request {
self.dataSource = [[[YourDataDataSource alloc]
initWithResults:results] autorelease];
}
and in your custom TTTableViewDataSource have your - (Class)tableView:(UITableView*)tableView cellClassForObject:(id) object
custom function
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.