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.3k stars 512 forks source link

Delegate method for when cells will be displated #40

Open kylefox opened 12 years ago

kylefox commented 12 years ago

It would be really nice to have something that tells the when a cell is about to be drawn on the screen. Methods such as:

willDisplayCell:atIndex: didDisplayCell:atIndex:

(Similar to tableView:willDisplayCell:forRowAtIndexPath: in UITableViewDelegate's)

Here's an example use case:

I am using GMGridView to display full-screen photos in a single row. The view controller allows captions (a UILabel on each cell's view) to be toggled on/off. I need a way to either show or hide this label just before the cell comes into view to ensure that the state is correct.

Using cellForItemAtIndex doesn't work, because the current, previous and next cells are all pre-loaded, so their state is incorrect. I've also tried calling [gridView reloadData] to force invalidate all the cells, but that causes the images to flicker.

Any suggestions?

gmoledina commented 12 years ago

Yup will definitely try to add these methods ! I'll be using the gridview in the exact same context as you so I'll be needing these methods too.

In the meantime, you can set yourself as the scroll delegate of the grid (the grid inherits from UIScrollView - in develop branch) and when you get the callback that the scrollview has stopped scrolling, you could check which cell is displayed based on their frame and the scroll's contentOffset (yes this is a very temporary solution).

kylefox commented 12 years ago

Ok thanks, I will move to the development branch and try your suggestion for now.

Unrelated: do you have any idea when you'll be merging the develop branch into master? It seems like there have been some API changes, and I'm wondering if I'm better off building my app against "develop" going forward.