I am using the following code to display an index for a TableView.
My problem is that pressing the magnifying glass icon, does not take me to the top of the table, where the search bar is. Every other section of the index works.
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
if (tableView == [[self searchDisplayController] searchResultsTableView])
return nil;
else {
//I add the magnifying glass to the index
NSArray *indexArray = [NSArray arrayWithObject:UITableViewIndexSearch];
// I return the array for the index after I add the rest of Index items
return [indexArray arrayByAddingObjectsFromArray:self.sectionsarray];
}
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
// I set index - 1 so I can compensate for the addition of the magnifying glass
return index -1;
}
What is the
-1section, i don’t know and you can use the following code instead for the section at the table header: