vilelam
vilelam

Reputation: 804

UITableview sections (Xcode 4.5 and iOS6)

I'm trying to create a UITableview with 2 sections. The first section should contain only one row and the second section should contain 6 rows. How do I define the number of sections? From the storyboard I could define that my table view style is grouped.

Any help will be appreciated.

Many thanks, Marcos

Upvotes: 0

Views: 242

Answers (2)

sooper
sooper

Reputation: 6039

You need to implement the UITableViewDataSource protocols to populate a table with sections and rows. See the Apple documentation here

Check the solution I submitted for this post; it should point you in the right direction.

Upvotes: 1

Tim
Tim

Reputation: 226

You supply all of that information at runtime, generally from the view controller. You need to set your view controller as the table view's 'data source', then implement the UITableViewDataSource protocol which is documented here:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html

The specific method that will determine how many sections are presented is this one:

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

Upvotes: 1

Related Questions