-(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.
Try return 0 in numberOfSectionsInTableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (result_not_found) { /// pass the condition when "result not found" here
return 0;
}
if (_segment.selectedSegmentIndex==0) {
return ([sortedKeys count]);
}
else {
return ([sortedKeys1 count]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With