nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
12.01k stars 2.58k forks source link

Issue with reloadItemAtIndex animated #417

Open elmyn opened 11 years ago

elmyn commented 11 years ago

As data source of iCarousel I'm using FetchResultController. In its delegate method I want to update views when data has changed. Its not refreshed get when I want to do this animated.

- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath {
    switch(type) {
        case NSFetchedResultsChangeInsert:
                    NSLog(@"31");
            [self.iCarousel insertItemAtIndex:newIndexPath.row animated:NO];;
            break;
        case NSFetchedResultsChangeUpdate:
            [self.iCarousel reloadItemAtIndex:indexPath.row animated:NO];
            break;
        default:
            break;
    }
}

With tableView its working with those two metods:

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
   [self.tableView endUpdates];
}

- (void)controllerWillChangeContent:(NSFetchedResultsController*)controller {
   [self.tableView beginUpdates];
}

is there something similar for

thisisjeffwong commented 11 years ago

Have you checked in the debugger that it's asking data source for carousel:viewForItemAtIndex:reusingView: (when you turn animation on?)

nicklockwood commented 11 years ago

No, there's no way to batch updates for iCarousel at the moment. If you're careful you should be able to insert/remove items individually, as long as you ensure that the data model remains consistent with the carousel (e,g, always add items to your model before inserting into carousel).