gmoledina / GMGridView

A performant Grid-View for iOS (iPhone/iPad) that allows sorting of views with gestures (the user can move the items with his finger to sort them) and pinching/rotating/panning gestures allow the user to play with the view and toggle from the cellview to a fullsize display.
MIT License
2.31k stars 512 forks source link

Infinite loop in loadRequiredItems #116

Closed Nosfi closed 12 years ago

Nosfi commented 12 years ago

I have a frequent and reproducible issue when reloading the grid with less items than the ones needed to fill the grid to the current page ( contentOffset ) wich I scrolled previously.

I'm using GMGridViewLayoutHorizontalPagedStrategy.

Example:

Load the grid with 50 items with 10 items per page, scroll to page 3. Then remove all items and reload, i recive a lot of calls to 'loadRequieredItems' and some of them have the 'contentOffset' with an 'x' from page 3 but the contentSize is only of 1 page now, so i get an incorrect 'rangeOfPositions' with lenght=Infinite.

To solve the issue temporaly I wrote this at the start of the method (Not much correct...but works):

if(self.contentOffset.x > self.contentSize.width || self.contentOffset.y > self.contentSize.height)
    self.contentOffset = CGPointMake(0, 0);
Nosfi commented 12 years ago

I think i had something messed up with my code, related to the events of my PageControl...I remade the control and the issue stoped to happen. Sorry for the inconvenience.