-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
if (_segment.selectedSegmentIndex==0)
{
return sortedKeys;
}
else
{
return sortedKeys1;
}
}
I use this code but i don't want section title if name is not present , now its give me all section titles
If there is no rows than set the title of the section to nil.
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if ([tableView.dataSource tableView:tableView numberOfRowsInSection:section] == 0)
{
return nil;
} else {
return "section title \(section)"
}
return @"";
}
This will work.