Skip to content

Commit

Permalink
revises a division-by-zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
Evadne Wu authored and AlanQuatermain committed Mar 5, 2011
1 parent 1e4fe3d commit c034f97
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Classes/AQGridView.m
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,18 @@ - (void) layoutSubviews
backgroundRect.size.height = backgroundRect.size.height + MAX_BOUNCE_DISTANCE;
}

CGFloat minimumHeight = rect.size.height;
CGFloat actualHeight = [_gridData cellSize].height * ([_gridData numberOfItems] / [_gridData numberOfItemsPerRow] + 1);
CGFloat minimumHeight = rect.size.height,
actualHeight = 0;

if (([_gridData numberOfItems] == 0) || ([_gridData numberOfItemsPerRow] == 0)) {

actualHeight = [_gridData cellSize].height;

} else {

actualHeight = [_gridData cellSize].height * ([_gridData numberOfItems] / [_gridData numberOfItemsPerRow] + 1);

}
for (; actualHeight < minimumHeight; actualHeight += [_gridData cellSize].height) {
}
backgroundRect.size.height = actualHeight;
Expand Down

0 comments on commit c034f97

Please sign in to comment.