【发布时间】:2014-01-12 10:47:47
【问题描述】:
我有一个非常标准的 UITableView,带有部分(A-Z - 没有数字或搜索)。
我已经实现了在表格右侧启用节索引(A-Z 栏)视图的委托方法。
我现在已经在表格中输入了足够的数据,使得大多数(不是全部,而是大多数)部分(即 A、B、C...Z)都有一个或多个单元格。
但是我注意到,现在该应用程序处于私人测试阶段,当有人触摸部分索引的字母时,表格跳转到的实际位置是不正确的。
它实际上对 A、B 和 C 是正确的,然后逐渐变得越来越错误 - 以至于 Z 实际上是条上“R”所在的位置。
这是在 iPad 上(仅限),并且没有对表格或部分索引视图进行特殊的“幕后”定制。
有什么想法吗?我已经在谷歌上搜索了将近一个小时,但找不到以前见过这个的人。
编辑:
这是我设置部分索引的代码:
- ( NSArray * ) sectionIndexTitlesForTableView:( UITableView * )tableView
{
[self customizeSectionIndexView]; // This just changes colours in iOS 7+
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
{
id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsControllerWithPredicate sections] objectAtIndex:section];
return [sectionInfo name];
}
- ( NSInteger ) numberOfSectionsInTableView:( UITableView * )tableView
{
NSInteger sectionCount = [[self.fetchedResultsControllerWithPredicate sections] count];
return sectionCount;
}
- ( NSInteger ) tableView:( UITableView * )tableView numberOfRowsInSection:( NSInteger )section
{
id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsControllerWithPredicate sections][section];
return [sectionInfo numberOfObjects];
}
所以我最多有 26 个部分,但我只是想显示其中包含单元格的部分。这是我要出错的地方吗?
当数据来自 Core Data 并且可以随时更改时,我该如何处理这种状态?
【问题讨论】:
标签: ios uitableview scroll indexing