我正在尝试使用以下代码索引我的UITableView
在我的ViewDidLoad
arrayOfTableView = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26", nil];
在我的sectionIndexTitlesForTableView
方法
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
NSArray *tempArray = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26", nil];
return tempArray;
}
在我的sectionForSectionIndexTitle
方法
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
return index;
}
它出现在我的表格视图旁边的索引栏。但是,当我点击 索引栏 ,它不会在那里。
我已经用NSLog
测试过了,那个事件是不是?这是事件。
但不要滚动到表视图。
请帮我找出答案。
我认为您需要检查您的numberOfSectionsInTableView:
方法。此外,还应仅为具有节索引列表的表视图实现此方法 (tableView:sectionForSectionIndexTitle:atIndex:
),该表视图只能是以纯样式 (UITableViewStylePlain) 创建的表视图。