Is there a standard way to display aggregate cell values in section headers, aligned with the cell in question, which supports horizontal scrolling, and supports expandable/collapsible sections?
Right now I can almost make it happen by overriding gridView:viewForSectionHeader, and returning a built-up view of UILabels positioned based on the IGCellPath of the first row of cells. However, it doesn't work when there is horizontal grid scrolling; the section header doesn't scroll along with the grid, which kind of makes sense because then how would the section title show.
I could alternatively just change the section title text to something like: "Section A: AggValue1:123.45 AggValue2:678.90", but that doesn't align up with the cells, which seems to be the limiting issue in all this.
Any other ideas that could work to simulate a section header that shows aggregate cells values aligned with the cell in question, horizontally scrolls well, and supports expandable/collapsible sections?
Thanks.
Buy Stun Guns
Hello,
As far as I understand from your post you’ve been able to solve your issue.
Please do not hesitate to contact with us if you have any further questions.
pathForRowAtPoint seems to work well.
One issue I noticed was that if the last row is in view (collapsed or not), the last row path is nil when I use:
IGRowPath *lastRow = [grid pathForRowAtPoint:CGPointMake(0, grid.contentOffset.y + grid.bounds.size.height)];
In that case, I set the last section index to my total number of sections - 1. Then I loop like previous through the section headers to scroll them.
Since I want the first column of the section header grid to be fixed as I scroll horizontally, I will attempt to fix that column, and everything should be perfect.
Ah, yea, i forgot that you used the Expandable Sections feature :)
Well, the pathsForVisibleRows was more of a shortcut, but you could just loop through all of your section headers, and see if cellAtPath: returns a cell for a particular section. This could be a bit expensive if you have a LOT of sections though.
I suppose another trick that should work is: to use pathForRowAtPoint:
You could pass in the contentOffset.y of the gridView for the top most row, and the contentOffset.y + gridView.bounds.size.height for the bottom most row
Then you could use the returned path to determine the top most section and the bottom most section.
-SteveZ
I've got most of it working except for a minor issue in the scrolling part...
pathsForVisibleRows only returns me the last row/section if all the sections are collapsed and all of those are in the visible area. Put alternately, pathsForVisibleRows does not include the collapsed sections that appear first in the visible area until a visible non-collapsed/last section is encountered.
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
if ([scrollView isKindOfClass:[IGGridView class]]) {
IGGridView *grid = (IGGridView*)scrollView;
NSArray *rowPaths = [grid pathsForVisibleRows]; // does not include the sections that are collapsed *****
if (rowPaths) {
IGRowPath *firstRow = rowPaths.firstObject;
IGRowPath *lastRow = rowPaths.lastObject;
int firstSectionIndex = firstRow.sectionIndex;
int lastSectionIndex = lastRow.sectionIndex;
for (int i = firstSectionIndex; i < lastSectionIndex + 1; i++) {
MySectionHeaderAggregateCell *sectionHeaderCell = [grid cellAtPath:[IGCellPath pathForRow:kSectionHeaderIndex inSection:i inColumn:-1]];
[sectionHeaderCell.grid setContentOffset:CGPointMake(grid.contentOffset.x, sectionHeaderCell.grid.contentOffset.y)];
}
Any ideas on how to get a reference to those visible collapsed section header cells that don't come over in paths for visible rows? I suppose I could try and just do it for all section header cells, any maybe test if they are visible, and scroll all of them.