Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Section within a section - UITableView -

I just have a question with regards to the tableView.

I know we can return the number of sections and rows with.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

Could you tell me how I can have something like :

  • A section within a section (and another section, if possible) - - And then configure the rows there ?

And what would I return in

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
like image 224
Legolas Avatar asked Jun 08 '11 14:06

Legolas


People also ask

Is it possible to add UITableView within a UITableViewCell?

Implementation of adding a table view inside the cell of UItableview aka, Nested Table View. Used the Power of Autosizing table view and delegate to achieve the expansion and collapse of the cell height.

What is Section in UITableView?

UITableView with sections allows us to separate the list into different categories, so the list looks more organized and readable. We can customize sections as per our need, but in this tutorial, we are covering the basic UITableview with sections. Here's is the video if you prefer video over text. Let Create An App.

What is indexPath section?

Index paths describe an item's position inside a table view or collection view, storing both its section and its position inside that section. For example, the first row in a table would have section 0, row 0, whereas the eighth row in the fourth section would have section 3, row 7.

What is indexPath UITableView?

IndexPath contains information about which row in which section the function is asking about. Base on this numbers you are configuring the cell to display the data for given row.


1 Answers

You will have to make your own implementation in cellForRowAtIndexPath where you return a row that is really made up of multiple rows and maybe a header label. Or maybe better is to make every other row a "header row" and check in cellForRowAtIndexPath whether you are on a "header row" or normal row; something like this:

if (indexPath.row == 0) {
     // return header row
} else {
     // return normal row
}

and of course in numberOfRowsInSection you will have to return the normal amount of rows + 1 for sections with a header.

like image 86
vakio Avatar answered Oct 16 '22 03:10

vakio