1
votes

I am having a problem with a table and showing another view when the user touches a table cell. I am using a UITabBarController for the main view to show different views. I then use a UINavigationController when the user selects a UITableView view to display the next view from the table cell selection.

My problem is this: when they select the table cell, the cell is highlighted and the next view does not appear. I am using IB. All of the examples I have found are doing this the same way I am, except the examples work!

I have the controllers loaded in a NSMutableArray with a Dictionary. I also tried this code by directly creating a view controller rather than using the array item. Same results....

I checked the target controller (Calc1ViewController) to make sure there was nothing wrong with the controller. When showing it directly, the controller (Calc1ViewController) displays correctly.

Here is some code.....

The initialization of the view controller in the dictionary:

Calc1ViewController *calc1ViewController = [[Calc1ViewController alloc] init];
[menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
                     NSLocalizedString(@"SSC - page 1",@""), @"title",
                     calc1ViewController, @"viewController",
                     nil]];
[calc1ViewController release];

I also tried this without using the dictionary -- creating a view controller in place of the [[menuList objectAtIndex:...]; line -- by creating the view controller like this:

Calc1ViewController *targetViewController = [[Calc1ViewController alloc] init];


// the table's selection has changed, switch to that item's UIViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *targetViewController = [[menuList objectAtIndex: indexPath.row] objectForKey:@"viewController"];
    [[self navigationController] pushViewController:targetViewController animated:YES];
    targetViewController = nil;
}

The navigation controller is defined in the AppDelegate and connected to the RootViewController through IB.

When I select a table row, it shows in the debugger that the pushViewController code is executed, but the next view does not show. Here is an example:

alt text http://thecoolestcompany.com/ssc-table-view.jpg

Any ideas?

3

3 Answers

1
votes

Finally figured it out......

I had the UINavigationController and the UITabBarController on the same level. After moving the Navigation Controller as a child to the tab bar controller, everything worked. You may add as many navigation controllers to a tab bar as you would like. In IB is is a little confusing. You need to drag the NavigationController into the TabBar to as it as a new Tab Bar item.

0
votes

Theres not much to go by with t he code you have provided. Only thing i can think of without looking at more code is that perhaps you have not initialized your view controller (the one in your dictionary) correctly, or at all, or the dictionary you are accesing there is not the correct one...

0
votes

What is the value of [self navigationController] when pushViewController is called. Is it nil?

What is the value of targetViewController when it is passed to pushViewController. Is it nil?