objective-c – 由NSFetchedResultsController支持的AQGridView

前端之家收集整理的这篇文章主要介绍了objective-c – 由NSFetchedResultsController支持的AQGridView前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图实现一个使用获取的结果控制器作为其数据源的AQGridView.

我不太确定如何使用网格视图来处理NSFetchedResultsController委托方法;即内容变化.我了解如何将FRC用于其他网格视图数据源代理.

有人可以指出我的方向正确吗?

解决方法

结果应该看起来有点像这样:
  1. - (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
  2. {
  3. [gridView beginUpdates];
  4. }
  5.  
  6. - (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo
  7. atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
  8. {
  9. switch(type)
  10. {
  11. case NSFetchedResultsChangeInsert:
  12. break;
  13. case NSFetchedResultsChangeDelete:
  14. break;
  15. }
  16. }
  17.  
  18. - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
  19. atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
  20. newIndexPath:(NSIndexPath *)newIndexPath
  21. {
  22.  
  23. ChannelPageViewController *currentPageController,*destinationPageController;
  24.  
  25. NSIndexSet * indices = [[NSIndexSet alloc] initWithIndex: indexPath.row];
  26. NSIndexSet *newIndices = [[NSIndexSet alloc] initWithIndex:newIndexPath.row];
  27.  
  28. switch(type) {
  29. case NSFetchedResultsChangeInsert:
  30. [gridView insertItemsAtIndices:newIndices withAnimation:AQGridViewItemAnimationNone];
  31. break;
  32.  
  33. case NSFetchedResultsChangeDelete:
  34. [gridView deleteItemsAtIndices:indices withAnimation:AQGridViewItemAnimationNone];
  35. break;
  36.  
  37. case NSFetchedResultsChangeUpdate:
  38. [gridView reloadItemsAtIndices:indices withAnimation:AQGridViewItemAnimationNone];
  39. break;
  40.  
  41. case NSFetchedResultsChangeMove:
  42. [gridView deleteItemsAtIndices:indices withAnimation:AQGridViewItemAnimationNone];
  43. [gridView insertItemsAtIndices:newIndices withAnimation:AQGridViewItemAnimationNone];
  44. break;
  45. }
  46. }
  47.  
  48. - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller
  49. {
  50. [gridView endUpdates];
  51. if ([[frc fetchedObjects] count] == 1) {
  52. [gridView reloadData];
  53. }
  54.  
  55. }

猜你在找的C&C++相关文章