-1
Я хочу сделать индексированную таблицу.Только одна секция в индексированной таблице
-(void)awakeFromNib
{
self.heroes = [NSArray arrayWithObjects: @"Aaaa",@"Abbbbb",@"Bbbbb",@"Nnnnn",@"Pppp",@"Xxxx",@"Zzzzz", nil];
}
- (NSArray *)sortedArrayFromArray:(NSArray *)array collationStringSelector:(SEL)selector{
return [NSArray arrayWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", nil];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [[[UILocalizedIndexedCollation currentCollation] sectionTitles] objectAtIndex: section];
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return [[UILocalizedIndexedCollation currentCollation] sectionIndexTitles];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
return [[UILocalizedIndexedCollation currentCollation] sectionForSectionIndexTitleAtIndex:index];
}
Но когда приложение запускается, есть только один индекс с именем «A». Что я делаю не так?
(Отображаются массивы правильно)
Спасибо!
У вас есть этот метод? - (NSInteger) numberOfSectionsInTableView: (UITableView *) tableView – Sauvage
здесь есть подробный пример http://www.iphonedevcentral.com/indexed-uitableview-tutorial/ – Sauvage