【发布时间】:2012-04-08 00:09:42
【问题描述】:
我正在使用以下代码来显示 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;
}
【问题讨论】:
标签: ios uitableview