Is there a way to change sectioned tableview to drilldown tableview?

I have a sectioned tableview with a plist wich is an array filled with dictionaries. In my app all sections and cells are shown on the first view. But now I need to change it to look like this: sections have to become cells(with names of sections). When you press this cell the cells contained in section have appear.

Is there a way to do it without too much rewriting the code?

Thanks and sorry for the noob question :o)


You will need to create two table view classes. One for the one that holds the section names, and the other that holds the rows of each section. In the first one, retrieve the section names from the plist and populate the rows in the table accordingly. Then in the - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method you need to push another view controller onto the navigation stack(something like this-provided in the template code):

// Navigation logic may go here. Create and push another view controller.

     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];

Then for the other table view class you populate it by reading in the info from the plist that corresponds to the tapped section. Hope this helps.

I understand, that you still want to use one tableview, where cells are hidden for all sections except one. In that case you can do this:

  • Implement -tableView:headerForSection: and place a button on the view that you will return. Write the sections number on the buttons tag. Add an action to the button with parameter (UIButton *)sender: `-(void) headerPressed:(UIButton *)sender
  • You need to implement -tableView:heightforHeaderInSection: as-well.
  • -(void) headerPressed:(UIButton *)sender writes the senders tag to a member integer and reloads the tableview.
  • in -tableview:numberOfRowsInSection: you return 0 if the sections int is not equal to the member integer you saved. If it is equal, return the number of rows in that section.

Need Your Help

read from a file while installation in nsis but do no copy it on the destination pc

file text installer nsis

I want to display the version on the installation dialog pages of nsis, by reading the version from a text file, but i have to copy this on the destination pc where the executable is run, but i wan...

Create a collection with users - my javacode ok?

java mongodb nosql

Im using java/mongodb. I would like to create a table (collection) with some users. Well, its working im just not sure about my coding style. Could be this good if i just want to add 3 new persons ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.