【发布时间】:2014-02-03 03:45:54
【问题描述】:
经过长时间阅读和检查代码,我很自豪能够拥有一个包含部分和部分标题的自定义表格视图,所有这些都由核心数据对象填充。现在我需要自定义部分标题和背景颜色。我已经看到它完成了,但是使用了viewForHeaderInSection 方法。在我的titleForHeaderInSection 方法中是不可能的吗?
这里有我的方法:
-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
id <NSFetchedResultsSectionInfo> theSection = [[self.fetchedResultsController sections]objectAtIndex:section];
NSString *sectionname = [theSection name];
if ([sectionname isEqualToString:@"text 1"]){
return @"Today";
}
else if ([sectionname isEqualToString:@"text 2"]){
return @"Tomorrow";
}
if ([[self.fetchedResultsController sections]count]>0){
id<NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections]objectAtIndex:section];
return [sectionInfo name];
}
else{
return nil;
}
}
【问题讨论】:
标签: ios uitableview