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)

Answers


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

bind keypress in jquery with no plugins

javascript jquery

i need a simple bind on a keypress (right arrow) but i just cant make it work

How do I use two pipes in Unix C?

c unix

I have a homework to do that says the following:

jQuery - Focus/Blur to Show/Hide input groups

javascript-events jquery

I have a little form with 2 groups of 3 inputs.

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.