Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5020
Collapsable Sections
posted

How do you collapse sections? I know there's three-or-so data source methods. One of them returns a BOOL, and it works... but is there a way to programmatically collapse or check the state of a collapsed section? The other two delegate methods seem like they're there for me to implement... and it would seem like the grid data source helper implements some magic. Right now, my solution is crude... I keep a mutable array of @(BOOL) and add a tap gesture recognizer to a custom section cell. It's a huge pain... please tell me I'm doing it wrong.

Please, publish the source to all your data source helpers. That source code would add an extra layer of code-based documentation, likely answering questions such as, "how did they expect us to interact with that control?"

Parents
No Data
Reply
  • 40030
    Offline posted

    Hey Caylan, 

    Is there a reason you're not just using the IGGridViewDataSourceHelpers?  Why are you trying to rewrite the logic? You know you can just derive from them and extend functionality wherever you like, right?

    Anyways, here is what the code does internally. It sounds like its doing something like you were doing. Although, i'm not sure why you're creating a custom section cell and putting logic in there. The IGGridViewSectionHeaderCell has the code needed already. 

        NSMutableArray* _collapsedSections;

    -(BOOL)gridView:(IGGridView *)gridView sectionExpanded:(NSInteger)section

    {

        NSNumber* sec = @(section);

        

        return ![_collapsedSections containsObject:sec];

    }

        

    -(void)gridView:(IGGridView *)gridView collapseSection:(NSInteger)section

    {

        NSNumber* sec = @(section);

        

        if(![_collapsedSections containsObject:sec])

        {

            [_collapsedSections addObject:sec];

            [gridView updateData];

        }

    }

        

    -(void)gridView:(IGGridView *)gridView expandSection:(NSInteger)section

    {

        NSNumber* sec = @(section);

       

        if([_collapsedSections containsObject:sec])

        {

            [_collapsedSections removeObject:sec];

            [gridView updateData];

        }

    }

    -SteveZ

Children