objective-c – 由NSFetchedResultsController支持的AQGridView
发布时间:2020-12-16 05:26:51 所属栏目:百科 来源:网络整理
导读:我试图实现一个使用获取的结果控制器作为其数据源的AQGridView. 我不太确定如何使用网格视图来处理NSFetchedResultsController委托方法;即内容变化.我了解如何将FRC用于其他网格视图数据源代理. 有人可以指出我的方向正确吗? 解决方法 结果应该看起来有点像
我试图实现一个使用获取的结果控制器作为其数据源的AQGridView.
我不太确定如何使用网格视图来处理NSFetchedResultsController委托方法;即内容变化.我了解如何将FRC用于其他网格视图数据源代理. 有人可以指出我的方向正确吗? 解决方法
结果应该看起来有点像这样:
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller { [gridView beginUpdates]; } - (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type { switch(type) { case NSFetchedResultsChangeInsert: break; case NSFetchedResultsChangeDelete: break; } } - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { ChannelPageViewController *currentPageController,*destinationPageController; NSIndexSet * indices = [[NSIndexSet alloc] initWithIndex: indexPath.row]; NSIndexSet *newIndices = [[NSIndexSet alloc] initWithIndex:newIndexPath.row]; switch(type) { case NSFetchedResultsChangeInsert: [gridView insertItemsAtIndices:newIndices withAnimation:AQGridViewItemAnimationNone]; break; case NSFetchedResultsChangeDelete: [gridView deleteItemsAtIndices:indices withAnimation:AQGridViewItemAnimationNone]; break; case NSFetchedResultsChangeUpdate: [gridView reloadItemsAtIndices:indices withAnimation:AQGridViewItemAnimationNone]; break; case NSFetchedResultsChangeMove: [gridView deleteItemsAtIndices:indices withAnimation:AQGridViewItemAnimationNone]; [gridView insertItemsAtIndices:newIndices withAnimation:AQGridViewItemAnimationNone]; break; } } - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { [gridView endUpdates]; if ([[frc fetchedObjects] count] == 1) { [gridView reloadData]; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |