There should be a simple solution, but after 4 hours of viewing StackExchange, I refuse and try to answer this question here:
Situation: iOS 5, Xcode 4.2.1 using storyboards
Setup:
- Root Navigation Controller = UITabBarController with 5 Elements
- Each tab refers to a UITableViewController (via segues), which works fine, automatically
- I have classes for each view controller and navigation controller (UITabBarController)
- I click on the tab, say “Program”, and show me a list of elements (in the linked UITableViewController), for example, one of these elements is “Sessions”
- I click Sessions, didSelectRowAtIndexPath is called just fine.
- Now I want to execute a segue (which I connected from this UITableViewController, not the cell, to the new UITableViewController and gave it an identifier.
I'm calling: [self performSegueWithIdentifier:@"programToSessions" sender:self];
prepareForSegue is called, but then nothing. No errors, no warnings. New UITableViewController is not displayed.
- Note: it appears, however, if I switch segue to "modal", but it drops / hides the original tab bar at the bottom (not intended ...)
So far, my problem seems to have had a likely solution. Navigation controller I figured that if I set up a link to the navigation manager in AppDelegate, it initiates / sets it as soon as the actual root navigation controller (in viewDidLoad) loads, i.e. something is mostly used line by line: app.navController = self.navigationController in viewDidLoad - this can work! Right? So, I changed the action of segue: [app.navController performSegueWithIdentifier:@"programToSessions" sender:self];
But nothing changes, it does not appear.
Any ideas?
It is decided:
There were a few problems. The main problem was that I missed the “navigation controller” between the UITabBarController and the UITableViewController. This can be done by adding a new “navigation controller” to the storyboard, then drag and drop from the UITabBarController (rootViewController) to this new controller and set RELATIONSHIP. Then drag RELATIONHIP into the UITableViewController. So, as indicated by the correct answer, it should look like this: UITabBarController → (relation) → UINavigationController → (relation) → UITableViewController
To load new UITableViewControllers on top of the last UITableViewController, just go and call it through the code. The final tree will look like this:
UITabBarController → (relation) → UINavigationController → (relation) → UITableViewController → (segue) → UITableViewController
Give segue id. In code use this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"loadMyDetailView" sender:self]; }
source share