Skip to content

Commit

Permalink
Fix divide by zero in -[AQGridView numberOfItemsPerRow]
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetrich authored and Ryan Petrich committed Dec 3, 2010
1 parent cf2dc26 commit 05e0645
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Classes/AQGridViewData.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,9 @@ - (NSUInteger) numberOfItemsPerRow

// work out how many rows we can fit
NSUInteger rows = (NSUInteger)floorf(_boundsSize.height / _actualCellSize.height);
NSUInteger cols = _numberOfItems / rows;
if ( _numberOfItems % rows != 0 )
cols++;

return ( cols );
if (rows == 0)
return 1;
return ((_numberOfItems - 1) / rows) + 1;
}

- (CGRect) cellRectAtIndex: (NSUInteger) index
Expand Down

0 comments on commit 05e0645

Please sign in to comment.