Naming Sections in Grouped UITableView
I have a grouped table view with two sections.. I have an NSArray which pulls in 5 secti开发者_如何学运维on titles from a database, I want the first section in the uitableview to have four rows, whose titles are set to the first four elements in the NSArray and the second section to contain a whose title is set to the last element in the array, how is this possible?
Everything depends on what you return from your data source's tableView:numberOfRowsInSection:
and numberOfSectionsInTableView:
methods. Sounds like you want 2 sections, with 4 rows in the first and 1 in the second — you can do this by checking indexPath.section
in numberOfRowsInSection:
and returning the appropriate value. Then in tableView:cellForRowAtIndexPath:
, you can use indexPath.section+indexPath.row
to get the overall row number.
精彩评论