reloadData doesnt work
Hi,
I'm modifyng my fetchedResultsController from my aqgridview, but reloadData doesnt display any cell. The method "gridView: (AQGridView *)gridView cellForItemAtIndex: (NSUInteger) index" is calling, but there isn't no cells displayed.
My code:
[NSFetchedResultsController deleteCacheWithName: nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"colection = %@", [self colection] ];
[fetchedResultsController.fetchRequest setPredicate:predicate];
NSError *error = nil;
if (![[self fetchedResultsController] performFetch:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
[comicGridView reloadData];
Thank you
Maybe the problem is in the method reloadData, exactly in: self.contentSize = [_gridData sizeForEntireGrid];
It seems that the contentSize resulting is wrong.
OK, solved. I had to change the "setContentSize: (CGSize) newSize" method in AQGridView.m:
-
(void) setContentSize: (CGSize) newSize { if ( (_flags.contentSizeFillsBounds == 1) && (newSize.height < self.bounds.size.height) ) newSize.height = self.bounds.size.height;
if (self.gridFooterView) { // In-call status bar influences footer position CGRect statusRect = [UIApplication sharedApplication].statusBarFrame; CGFloat statusHeight = MIN(CGRectGetWidth(statusRect), CGRectGetHeight(statusRect)) - 20;
CGFloat footerHeight = CGRectGetHeight(self.gridFooterView.bounds); CGFloat minimumHeight = statusHeight + CGRectGetHeight(self.bounds) + footerHeight; if (newSize.height < minimumHeight) newSize.height = minimumHeight;}
newSize.height = fmax(newSize.height, self.frame.size.height+1); CGSize oldSize = self.contentSize; [super setContentSize: newSize];
if ( oldSize.width != newSize.width ){ [_gridData gridViewDidChangeBoundsSize: newSize]; }
if ( CGRectGetMaxY(self.bounds) > newSize.height ) { CGRect b = self.bounds; CGFloat diff = CGRectGetMaxY(b) - newSize.height; b.origin.y = MAX(0.0, b.origin.y - diff); self.bounds = b; } }
Check the difference:
- if (newSize.height < footerHeight + minimumHeight)
- if (newSize.height < minimumHeight)
Before, 'footerHeight' is summed twice.