section得指定的,不然只有一个
#pragma mark - Table索引
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
NSArray * array = [NSArray arrayWithObjects:@"A",@"B", nil];
return array;
}
//section (标签)标题显示
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSArray * array = [NSArray arrayWithObjects:@"A",@"B", nil];
return [array objectAtIndex:section];
}
//点击右侧索引表项时调用
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
NSArray * array = [NSArray arrayWithObjects:@"A",@"B", nil];
NSString *key = [array objectAtIndex:index];
NSLog(@"sectionForSectionIndexTitle key=%@",key);
if (key == UITableViewIndexSearch) {
[tableView setContentOffset:CGPointZero animated:NO];
return NSNotFound;
}
return index;
{
NSArray * array = [NSArray arrayWithObjects:@"A",@"B", nil];
return array;
}
//section (标签)标题显示
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSArray * array = [NSArray arrayWithObjects:@"A",@"B", nil];
return [array objectAtIndex:section];
}
//点击右侧索引表项时调用
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
NSArray * array = [NSArray arrayWithObjects:@"A",@"B", nil];
NSString *key = [array objectAtIndex:index];
NSLog(@"sectionForSectionIndexTitle key=%@",key);
if (key == UITableViewIndexSearch) {
[tableView setContentOffset:CGPointZero animated:NO];
return NSNotFound;
}
return index;
}