NSFetchedResultsController的didChangeSection方法未被调用(错误)

时间:2013-03-14 18:59:34

标签: ios xcode uitableview nsfetchedresultscontroller

我的NSFetchedResultsController的didChangeSection方法未被调用。我在网上搜索过,发现可能是因为sectionNameKeyPath使用transient属性会导致这个问题。从这里开始:"didChangeSection:" NSfetchedResultsController delegate method not being called

这真的是因为短暂的财产吗?以及如何在sectionNameKeyPath使用transient属性时调用didChangeSection?我使用viewForHeaderInSection来自定义节头,如何在不使用didChangeSection方法的情况下更新它?

现在我在[self.tableView reloadDate]中使用了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]放在模态视图的close视图方法的前面位置,视图将快速关闭并可以看到单元格插入动画。

0 个答案:

没有答案
相关问题