1. 程式人生 > >自定義UITableView的右側索引

自定義UITableView的右側索引

// 右邊索引的標題陣列
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
NSMutableArray *array = [NSMutableArray array];
for(int section='A';section<='Z';section++)
{
[array addObject:[NSString stringWithFormat:@"%c",section]];
}
return array;
}
// 自定義索引與陣列的對應關係
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
return (index+1==26)?0:(index+1);
}