- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
[self.tableView endUpdates];
}
在操作数据的时候,增删改查,会crash在这个方法里面,打印日志显示如下:
CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to insert row 1 into section 1, but there are only 1 rows in section 1 after the update with userInfo (null)
网上出现类似问题:http://blog.csdn.net/gukong/article/details/34161385 参考,共同解决这个问题。
出现这个问题的主要原因就是
- (void)controller:(NSFetchedResultsController *)controller
didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex
forChangeType:(NSFetchedResultsChangeType)type
{
[self.tableView beginUpdates];
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:sectionIndex];
switch (type) {
case NSFetchedResultsChangeInsert: {
[self.tableView insertSections:indexSet
withRowAnimation:UITableViewRowAnimationFade];
break;
}
case NSFetchedResultsChangeDelete:{
[self.tableView deleteSections:indexSet
withRowAnimation:UITableViewRowAnimationFade];
break;
}
default:
break;
}
[self.tableView endUpdates];
}
就是tablview的一些删除,更新,插入,的动画操作代码,应该放入到, [self.tableView beginUpdates];[self.tableView endUpdates];和这个方法中间,一般,在添加,删除,选择 tableView中使用,并实现动画效果。 在动画块内,不建议使用reloadData方法,如果使用,会影响动画。 一般在UITableView执行:删除行,插入行,删除分组,插入分组时,使用!用来协调UITableView的动画效果。
[self.tableView endUpdates];
}
在操作数据的时候,增删改查,会crash在这个方法里面,打印日志显示如下:
CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to insert row 1 into section 1, but there are only 1 rows in section 1 after the update with userInfo (null)
网上出现类似问题:http://blog.csdn.net/gukong/article/details/34161385 参考,共同解决这个问题。
出现这个问题的主要原因就是
- (void)controller:(NSFetchedResultsController *)controller
didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex
forChangeType:(NSFetchedResultsChangeType)type
{
[self.tableView beginUpdates];
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:sectionIndex];
switch (type) {
case NSFetchedResultsChangeInsert: {
[self.tableView insertSections:indexSet
withRowAnimation:UITableViewRowAnimationFade];
break;
}
case NSFetchedResultsChangeDelete:{
[self.tableView deleteSections:indexSet
withRowAnimation:UITableViewRowAnimationFade];
break;
}
default:
break;
}
[self.tableView endUpdates];
}
就是tablview的一些删除,更新,插入,的动画操作代码,应该放入到, [self.tableView beginUpdates];[self.tableView endUpdates];和这个方法中间,一般,在添加,删除,选择 tableView中使用,并实现动画效果。 在动画块内,不建议使用reloadData方法,如果使用,会影响动画。 一般在UITableView执行:删除行,插入行,删除分组,插入分组时,使用!用来协调UITableView的动画效果。