0

我的 NSFetchedResultsController 的 didChangeSection 方法没有被调用。我在网上搜索过,发现可能是对 sectionNameKeyPath 使用瞬态属性会导致这个问题。从这里:“didChangeSection:” NSfetchedResultsController 委托方法没有被调用

这真的是因为瞬态属性吗?以及如何在对 sectionNameKeyPath 使用瞬态属性时调用 didChangeSection?我使用 viewForHeaderInSection 自定义节标题,如何在没有 didChangeSection 方法的情况下让它更新?

现在我用[self.tableView reloadDate]in viewWillAppear,但是添加或删除一个项目后感觉有点慢,虽然可能是 0.5 秒。

我的 fetchedResultsController 的设置就像 DateSectionTitles,Apple 的一个示例:http: //developer.apple.com/library/ios/#samplecode/DateSectionTitles/Introduction/Intro.html

该示例很简单,仅包含- (NSFetchedResultsController *)fetchedResultsController在获取结果控制器部分中。我添加了一些与 tableview 相关的方法:

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath

- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller

只是- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type没有被调用。

我使用日期作为部分标题,但需要更新部分标题的另一部分,即行项目金额的总和。

更新:我错了。它正在被调用。我想插入一个单元格(不是新部分),应该调用 didChangeSection 并更新我自定义的部分标题。但是 didChangeSection 仅被调用以插入删除部分。只需使用 [self.tableView reloadDate],节标题将更新单元格更改。

我尝试将 [self dismissViewControllerAnimated:YES completion:NULL] 放在模态视图的关闭视图方法的前面位置,视图将快速关闭并且可以看到单元格插入动画。

4

0 回答 0