gmoledina/GMGridView — Issue #26: Incorrect contentSize calculation in GMGridViewLayoutHorizontalPagedStrategy
Author: rantav
Created: 2012-01-14 13:26:27+00:00
State: open

IMO there's a small error when calculating the _contentSize (and specifically the width) when minEdgeInsets sets only the left inset but not the right inset. This is probably the same case for top+bottom.

For example:

gmGridView.minEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);

This results in a grid nicely centered (with 20px from each side, left and right), but when the grid has many pages (more than 20 in my testing) then not all pages are displayed.
To fix this specific case I do:

gmGridView.minEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 20);

However, this shows that probably even though the grid is centered for each page, the right edges insets aren't taken into proper consideration when calculating the entire grid width so that when the number are large enough, this error results in some of the last pages missing.
BTW, I did not set the centered property.

The faulty code is probably at GMGridViewLayoutStrategies.m, line 400

_contentSize = CGSizeMake((onePageSize.width + self.edgeInsets.left + self.edgeInsets.right) * self.numberOfPages,
onePageSize.height + self.edgeInsets.top + self.edgeInsets.bottom);

`self.edgeInsets.right` is 0 so this results in a wrong calculation.