AQGridView icon indicating copy to clipboard operation
AQGridView copied to clipboard

reloadData doesnt work

Open jonathannaguin opened this issue 14 years ago • 2 comments

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

jonathannaguin avatar May 18 '11 11:05 jonathannaguin

Maybe the problem is in the method reloadData, exactly in: self.contentSize = [_gridData sizeForEntireGrid];

It seems that the contentSize resulting is wrong.

jonathannaguin avatar May 18 '11 14:05 jonathannaguin

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.

jonathannaguin avatar May 18 '11 14:05 jonathannaguin