UITableView节标题为空白且闪烁 [英] UITableView section headers are blank and flickering

查看:33
本文介绍了UITableView节标题为空白且闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- (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];

}

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

The code above groups the cells in alphabetical order but displays a blank gray header instead of the appropriate title. Could this possibly be because I did not specify the number of headers? This would naturally be a single header for every letter in the alphabet. Any other ideas why the cell headers would flicker white to gray, gray to white as I scrolled?

推荐答案

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

Repeated calls to tableView:titleForHeaderInSection: appear to return alternately [sectionInfo indexTitle] and nil. Why are you surprised?

这篇关于UITableView节标题为空白且闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆