如何在分段的UITableView中应用ROW上的索引

时间:2015-06-09 03:46:37

标签: ios objective-c uitableview

我有一个UITableview的分区。这样的事情: enter image description here

重要代码是:

animals = @{@"B" : @[@"Bear", @"Black Swan", @"Buffalo",@"TIGER"],
            @"C" : @[@"Camel", @"Cockatoo",@"Tarantula"],
            @"D" : @[@"Dog", @"Donkey",@"Tasmanian Devil"],
            };

animalSectionTitles = [NSArray arrayWithObjects:@"B",@"C",@"D", nil];
animalIndexTitles = @[@"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"];

相关代表:

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return animalIndexTitles;
}

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
return [animalSectionTitles indexOfObject:title];
}

现在的要求是,如果我从索引中按“T”,表格应显示所有带有“T”的结果,以及它们的sect5ion,例如B和C部分都有单词(tiger和Tarantula)。如果我从索引中按“T”,表格应该显示带有行虎的“B”部分和带有狼蛛的“C”部分。

我怎样才能实现这一点。我正在考虑删除所有索引内容,只需使用带搜索功能的搜索栏。

0 个答案:

没有答案