Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support grid header view and grid footer view #21

Open
luosheng opened this Issue · 15 comments
@luosheng

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

@steipete

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

@gmoledina
Owner

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

@aquarius

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

@gmoledina
Owner

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

@aquarius

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

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
Owner

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 ?

@kielgillard

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

@andrewtheis

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?

@andrewtheis

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

+1

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

@m2d2

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

@bencallis

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

+1

I'm interested in this too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.