gpt4 book ai didi

ios - UITableView sectionForSectionIndexTitle 方法不会在 iOS 中滚动 tableview

转载 作者:行者123 更新时间:2023-12-01 19:13:50 24 4
gpt4 key购买 nike

我正在尝试索引我的 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;
}

它出现在我的 tableview 旁边的 IndexBar 。但是,当我点击 IndexBar 时,它并没有滚动到那里。

我已经用 NSLog 进行了测试,那个事件与否?是事件。

但不要滚动到 tableView。

请帮我找出答案。

最佳答案

我认为您需要检查您的numberOfSectionsInTableView:方法。
此外,您应该只为具有节索引列表的 TableView 实现此方法(tableView:sectionForSectionIndexTitle:atIndex:)——它只能是以普通样式(UITableViewStylePlain)创建的 TableView 。

关于ios - UITableView sectionForSectionIndexTitle 方法不会在 iOS 中滚动 tableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14576977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com