Skip to content

How to not show sections in table #3

Description

@lgadams

Hi Xenofex,

I have been playing around with the grid and have been trying to find an easy way to not use sections.

What I have come up with, which I think needs some work is something like this:

In your example, I have modified viewDidLoad in MultiColumnTableViewController.m to look like this:

- (void)viewDidLoad
{
[super viewDidLoad];
    numberOfColumns = 5;
    numberOfRows = 30;
    numberOfSections = 1;

    colWidth = 240.0f;
    headerHeight = 100;
    headerWidth = colWidth;

    data = [[NSMutableArray alloc] initWithCapacity:numberOfRows];

    for (int i = 0; i < numberOfRows; i++) 
    {        
            NSMutableArray *rowArray = [NSMutableArray arrayWithCapacity:numberOfColumns];
            for (int j = 0; j < numberOfColumns; j++) {
                [rowArray addObject:text];
            }

            //[sectionArray addObject:rowArray];
        [data addObject:rowArray];        
    }


    tblView = [[EWMultiColumnTableView alloc] initWithFrame:CGRectInset(self.view.bounds, 5.0f, 5.0f)];
//    tblView.sectionHeaderEnabled = YES;
//    tblView.cellWidth = 100.0f;
//    tblView.boldSeperatorLineColor = [UIColor blueColor];
//    tblView.normalSeperatorLineColor = [UIColor blueColor];
//    tblView.boldSeperatorLineWidth = 10.0f;
//    tblView.normalSeperatorLineWidth = 10.0f;
    tblView.dataSource = self;
    tblView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:tblView];
}

and modified this method to just return the number of rows…

- (NSInteger)tableView:(EWMultiColumnTableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [data count];
}

Is there an easier and more readable way to not use sections and just have pure rows in the grid? I couldn't really see any other way with out extending the API a bit...

Also, is there a more dynamic way to calculate the width/height of the columns rather than hard coding them? Sorry I am new to iOS programming.

Thanks!

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions