Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Support grid header view and grid footer view #21

luosheng opened this Issue Dec 22, 2011 · 15 comments


None yet

I know it doesn't quite make sense in horizontal mode, but it would really be nice to have them in vertical mode.


steipete commented Dec 22, 2011

Yep, i want this too. Shouldn't be that hard (as compared to section headers)


gmoledina commented Dec 22, 2011

Just one header for the entire grid (with the benefit of scrolling with the grid content) or header per section ?

aquarius commented Jan 5, 2012

I also needed support for a grid header view. I added it to my fork:


gmoledina commented Jan 8, 2012

It only seems to make sense for the Vertical Strategy. Looks weird for Horizontal strategies, specially the paged ones.

Right, you probably need to attach it to the grid view directly if you have paging enabled so it always stays on top.

How would you solve this? Add a BOOL to the layout strategy to indicate how the header/footer views are positioned (sticky or scrolling)?


steipete commented Jan 12, 2012

I'm also very interested in the header view; we can add simple support for now and improve it with different layouts later.
Any opposition to that?


gmoledina commented Jan 13, 2012

Sure no problem. I was thinking of a solution in the same direction as the layout strategy idea; as in giving the user control on how to position the header. So the core code doesn't has no logic about specifics headerView positioning behavior.

I like Markus's implementation of the headerview, that could be the headerViewContainer. And then the user can set any other view responding to a protocol with callbacks for when the scroll is scrolled for example, so the user can choose the reposition it's own headerView if needed.

The method to set the headerView could be setHeaderView:withSuggestedSize:
In the case of vertical layout, the headerView width will be that of the scroll frame and the height will be the above specified parameter. In the case of horizontal layout, the height will be that of the scroll frame and the width will be the above specified parameter.

What do you think? Is it overkill ?

I'm interested in the addition of this API, too.

+1 !

I'm adding a header for the whole Grid in interface builder, and using setMinEdgeInsets: to shift the grid content down. This would work great except cells are dequeued & removed from the view prematurely when scrolling up (about 1 grid row distance). Thoughts? Am I using setMinEdgeInsets incorrectly?

Figured this out: When calculating out the rows to display, the vertical layout strategy doesn't take into account the minEdgeInsets. I changed line 225 in GMGridViewLayoutStrategies to:

CGFloat firstRow = MAX(0, (int)((contentOffset.y - self.edgeInsets.top) / itemHeight) - 1);

kylefox commented Jun 26, 2012


Any updates on this? Would really love to (easily) add a header view in vertical mode.

m2d2 commented Jul 6, 2012

andrewtheis, fantastic catch on the layout strategy. aquarius branch + your fix made everything work :)

Did anyone ever implement this? I was hopping to included a searchbar at the top of the grdiview. So when you pull down it appears (like in mail).

neoneye commented Jan 25, 2013


I'm interested in this too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment