Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reloadData doesnt work #66

Open
jonathannaguin opened this issue May 18, 2011 · 2 comments
Open

reloadData doesnt work #66

jonathannaguin opened this issue May 18, 2011 · 2 comments

Comments

@jonathannaguin
Copy link

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
Copy link
Author

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

It seems that the contentSize resulting is wrong.

@jonathannaguin
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant