-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
if (_segment.selectedSegmentIndex==0)
{
return sortedKeys;
}
else
{
return sortedKeys1;
}
}
我使用这段代码,但如果名称不存在,我不想要部分标题,现在它给我所有部分标题
最佳答案
如果没有行,则将部分的标题设置为 nil。
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0)
{
return nil;
} else {
return "section title \(section)"
}
return @"";
}
这会起作用。
关于ios - 如果在 iOS 8 中使用搜索栏找不到结果,如何隐藏部分标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33120078/