NUCLiOS IGGridView: Stretch Rows

Stephen Zaharuk / Thursday, November 20, 2014

Even if you're an IGGridView pro, you might not have known about the Stretch Row feature, although if you've used our Samples Browser, you've seen it and used it plenty of times. 

Stretch Rows are basically exactly what they sounds like. Essentially, they're rows that have only one column, even if DataSourceHelper has Multiple columns being displayed. 

Believe it or not, the area above the Layout Section Header, where the Images are, is another Row in the same IGGridView. We're simply declaring it as a Stretch Row.

So how do we do that? Well its just a single method on the IGGridViewDataSourceProtocol. 

So if you're implementing the protocol yourself, you'll simply add this method to your implementation. Or if you're using an IGGridViewDataSourceHelper, you just drive from that DSH and override the method yourself. 

Here is the signature of the method:

-(NSArray*)rowPathsOfStretchRowsInGridView:(IGGridView*)gridView

And here is how you use it:

-(NSArray*)rowPathsOfStretchRowsInGridView:(IGGridView*)gridView

{

    return @[[IGRowPath pathForRow:0 inSection:0]];

}

Yup, its thats simple. 

Basically, we just pass the IGRowPath of the row/rows that should be treated as a single column that fills the viewport. Once you do that, that row will not adhere to columns anymore, and you're free to render what you'd like in there. 

I hope you found this useful!

-SteveZ