custom cells uitableview - cannot display all the rows

Posted by Matt Facer on Stack Overflow See other posts from Stack Overflow or by Matt Facer
Published on 2010-04-10T17:09:51Z Indexed on 2010/04/10 17:13 UTC
Read the original article Hit count: 303

Hi guys,

I'm creating a uitableview with custom cells which I created in Interface Builder. There are currently three cells (UITableViewCell).

I have a UITableView which is on the view.

The code I have is fairly standard, but I cannot work out how to actually SHOW the three custom cells. I am using the cellForRowAtIndexPath method.

My aim is to get a grouped uitableview which shows like the following

Item
  - Name

Settings
  - alert
  - time

So the above indented view should be my grouped uitableview. The problem is, I cannot get it to show using code. The uitableview will ALWAYS be this. I am trying to replicate the settings style screen... so I do not have any arrays to display the uitableview cells.

How do I actually display my three cells? I have the following code

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) 
        return 1;
    else 
        return 2;

}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    if(section == 0) 
        return @"Item";
    else
        return @"Settings";
}

So all I need to know is how to actually display my custom cells inside the tableview! Thanks for any information. I've searched for AGES in google .. all the tutorials use arrays to display data!

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about uitableview