Нажатие на значок увеличительного стекла в индексе UiTableView - PullRequest
1 голос
/ 23 марта 2012

Я использую следующий код для отображения индекса для TableView. Моя проблема в том, что нажатие на значок лупы не приводит меня к верхней части таблицы, где находится панель поиска. Все остальные разделы индекса работают.

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

1 Ответ

2 голосов
/ 23 марта 2012

Что такое раздел -1, я не знаю, и вы можете использовать следующий код для раздела в заголовке таблицы:

if(index == 0)     
  [tableView scrollRectToVisible:CGRectMake(0, 0, self.mySearchBar.width, self.mySearchBar.height) animated:YES];
return index -1;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...