Note that there are some explanatory texts on larger screens.

plurals
  1. POSegue firing but not pushing / UITabBarController / UITableViewController when cell clicked
    primarykey
    data
    text
    <p>There must be a simple solution to this, but after 4 hours of browsing StackExchange, I'm giving up and trying to get this answered here:</p> <p>Situation: iOS 5, Xcode 4.2.1, using Storyboards</p> <p>Setup:</p> <ul> <li>Root Navigation Controller = UITabBarController with 5 items</li> <li>Each tab links to a UITableViewController (via segues), which works perfectly, automatically</li> <li>I have classes for each view controller and the navigation controller (UITabBarController)</li> <li>I click on a tab, say "Program", and it shows me a list of items (in the linked UITableViewController), say one of these items is "Sessions"</li> <li>I click on "Sessions", didSelectRowAtIndexPath gets called just fine.</li> <li>I want to perform a segue now (which I have connected from that UITableViewController, not the cell, to the new UITableViewController and given it an identifier.</li> <li><p>I call: <code>[self performSegueWithIdentifier:@"programToSessions" sender:self];</code></p></li> <li><p>prepareForSegue gets called, but nothing afterwards. No error, no warning. The new UITableViewController doesn't show up.</p></li> <li>Note: It DOES show up, however, if I switch the segue to a "modal" - but it discards/hides the original tab bar at the bottom then (not intended...)</li> </ul> <p>So far, my problem seemed to have a likely solution. The navigation controller. I figured, if I setup a navigation controller reference in the AppDelegate, initiated/set it once the actual root navigation controller is loaded (in viewDidLoad), i.e. basically used something along the lines of: <code>app.navController = self.navigationController</code> in the viewDidLoad - this could work! Right? So, I changed the segue action to: <code>[app.navController performSegueWithIdentifier:@"programToSessions" sender:self];</code></p> <p>Yet, nothing changes, it does not show up. </p> <p>Any ideas?</p> <p><strong>Solved:</strong></p> <p>There were a few issues here. Major issue was the fact that I missed putting a "Navigation Controller" between the UITabBarController and the UITableViewController. This can be done by adding a new "Navigation Controller" to the storyboard, then drag from UITabBarController (the rootViewController) to this new controller and set a RELATIONSHIP. Next, drag a RELATIONSHIP to the UITableViewController. So, as outlined by the correct answer it should look like: UITabBarController --> (relationship) --> UINavigationController --> (relationship) --> UITableViewController</p> <p>In order to load new UITableViewControllers on top of the last UITableViewController, a simple segue and calling it through code will suffice. The final tree will look like:</p> <p>UITabBarController --> (relationship) --> UINavigationController --> (relationship) --> UITableViewController --> (segue) --> UITableViewController</p> <p>Give the segue an identifier. In code, use this:</p> <pre><code> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"loadMyDetailView" sender:self]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload