Generate new UITableViewController and show it

I'm working with tableviews showing a hierarchy data structure. I take the first node and show the sons in the tableview and repeat it until the end of the tree. I'm doing it in this way:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if([[actualNode getSonAtIndex:0] sonsCount]>0) {
    NSLog(@"New level");
    actualNode = [actualNode getSonAtIndex:indexPath.row];
    [self.tableView reloadData];
} else {
    NSLog(@"Service");
    [self performSegueWithIdentifier:@"Service" sender:NULL];
}

It is not the correct way but the problem is that I don't know how many levels has the tree so I can't create them in the Storyboard. The idea is create only one TableView for showing each level but doing it in that way I can't go back to the previous level on the NavBar like I could do if I was working with some controllers in the storyboard and I don't have animations. So, is there any way to do it? something like:

MyNextLevel *nextlevel = [MyNextLevel alloc];
[nextlevel setNode: actualNode]
Myactualtableview = nextlevel; (Here the next level is showed in the screen with animations and with the possibility to go back to the previous level)

Thanks.

Answers


This is why I don't like storyboards. It has always been possible to do what you want to do (if I'm understanding it correctly), but storyboards detract from it; they don't have the flexibility of doing things in code, which is what we always had to do back in iOS 3 and iOS 4 anyway.

Anyhow, you want to do something like this:

UITableViewController* tvc = [[MyTableViewController alloc] initWithNibName:@"MyNib" bundle:nil];
[self.navigationController pushViewController:tvc animated:YES];

Your business logic can just pick the class for MyTableViewController. Alternatively, MyTableViewController could be something flexible, where between those two lines you give it some configuration info that causes it to show the right data! (I have to admit, though, that you could do that same thing using a storyboard, configuring the table view controller in performSegue:.)


Need Your Help

Matlab array of audioplayers

matlab labview

I am creating a matlab script inside labview. Inside that script I try to create an array of audioplayer objects. However, I got an error, and I can't find a way around it.

Iterating over a year to get each days NSDate object in Swift

ios swift nsdate nsdatecomponents

Hello I have a method that returns an array of times for each day.

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.