UITableView 强制 sectionIndex 更新而不调用 reloadData

UITableView force sectionIndex to update without calling reloadData

我正在从 PHChange 实例修改我的 UITableView 的数据源,这工作正常。我不明白的是,我无法更新 UITableView 右侧的 sectionIndex,除非您重新加载整个 UITableViewreloadData.

有没有其他方法强制更新UITableView右边的sectionIndex?如果我手动调用:sectionIndexTitlesForTableView: 我确认我正在取回新数据,但是右侧的旧 sectionIndex 没有视觉上的变化,这正是我需要的。

代码:

PHFetchResultChangeDetails *changeDetails = [changeInstance changeDetailsForFetchResult:oldFetch];

if (changeDetails)
{
   PHFetchResult *fetchResultAfterChange = changeDetails.fetchResultAfterChanges;

   if (fetchResultAfterChange.count < 1)
   {
       [subArray removeObjectAtIndex:subIdx];

       dispatch_async(dispatch_get_main_queue(),^
       {
            NSIndexPath *path = [NSIndexPath indexPathForRow:subIdx inSection:idx];

            [self.albumsTableView deleteRowsAtIndexPaths:@[path] withRowAnimation:UITableViewRowAnimationNone];

            // Confirmed data is updating            
            NSLog(@"%@",[self sectionIndexTitlesForTableView:self.albumsTableView]);

            // Does nothing                    
            [self.albumsTableView setNeedsDisplay];
        });
    }
}

试试这个功能

- reloadSectionIndexTitles

This method gives you a way to update the section index after inserting or deleting sections without having to reload the whole table.