UITableView节标题是空白和闪烁

时间:2010-06-11 14:59:03

标签: iphone objective-c

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:section];

if ([tempArray containsObject: [sectionInfo indexTitle]])
{
    [tempArray removeObjectAtIndex:[tempArray indexOfObject:[sectionInfo indexTitle]]];     
    return nil;
}else
{
    [tempArray addObject: [sectionInfo indexTitle]];
    return [sectionInfo indexTitle];

}
return [sectionInfo indexTitle];

}

上面的代码按字母顺序对单元格进行分组,但显示的是空白灰色标题,而不是相应的标题。这可能是因为我没有指定标题数量吗?对于字母表中的每个字母,这自然是单个标题。任何其他的想法为什么当我滚动时,单元格标题会闪烁白色到灰色,灰色到白色?

1 个答案:

答案 0 :(得分:1)

重复调用tableView:titleForHeaderInSection:似乎交替返回[sectionInfo indexTitle]和nil。你为什么感到惊讶?

相关问题