-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