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

layout all cells after HeaderView's height was changed #113

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions Classes/AQGridView.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ - (void) deleteVisibleCell: (AQGridViewCell *) cell atIndex: (NSUInteger) visibl
@interface AQGridView ()
@property (nonatomic, copy) NSIndexSet * animatingIndices;
- (void) cellUpdateAnimationStopped: (NSString *) animationID finished: (BOOL) finished context: (void *) context;
- (void) handleGridViewBoundsChanged: (CGRect) oldBounds toNewBounds: (CGRect) bounds;
@end


Expand Down Expand Up @@ -357,6 +358,9 @@ - (void) setGridHeaderView: (UIView *) newHeaderView
[_headerView removeFromSuperview];

_headerView = newHeaderView;

CGFloat oldHeight = _gridData.topPadding;

if ( _headerView == nil )
{
_gridData.topPadding = 0.0;
Expand All @@ -367,6 +371,10 @@ - (void) setGridHeaderView: (UIView *) newHeaderView
_gridData.topPadding = _headerView.frame.size.height;
}

if ( _gridData.topPadding != oldHeight )
{
[self handleGridViewBoundsChanged:self.bounds toNewBounds:self.bounds];
}
[self setNeedsLayout];
}

Expand All @@ -383,6 +391,8 @@ - (void) setGridFooterView: (UIView *) newFooterView
[_footerView removeFromSuperview];

_footerView = newFooterView;

CGFloat oldHeight = _gridData.bottomPadding;
if ( _footerView == nil )
{
_gridData.bottomPadding = 0.0;
Expand All @@ -393,6 +403,9 @@ - (void) setGridFooterView: (UIView *) newFooterView
_gridData.bottomPadding = _footerView.frame.size.height;
}

if ( _gridData.bottomPadding != oldHeight ) {
[self handleGridViewBoundsChanged:self.bounds toNewBounds:self.bounds];
}
[self setNeedsLayout];
}

Expand Down Expand Up @@ -654,6 +667,14 @@ - (void) layoutSubviews
if ( (_flags.needsReload == 1) && (_animationCount == 0) && (_reloadingSuspendedCount == 0) )
[self reloadData];

if ( (_headerView && _gridData.topPadding != _headerView.frame.size.height ) ||
(_footerView && _gridData.bottomPadding != _footerView.frame.size.height) )
{
_gridData.topPadding = _headerView.frame.size.height;
_gridData.bottomPadding = _footerView.frame.size.height;
[self handleGridViewBoundsChanged:self.bounds toNewBounds:self.bounds];
}

if ( (_reloadingSuspendedCount == 0) && (!CGRectIsEmpty([self gridViewVisibleBounds])) )
{
[self updateVisibleGridCellsNow];
Expand Down