tags:

views:

19

answers:

1

Hello,

I've got UITableViewController and the body of the tableView:didSelectRowAtIndexPath: method is following:

if (indexPath.row == 0) {
    MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    [self.navigationController pushViewController:myViewController animated:NO];
    [myViewController release];
}

[tableView deselectRowAtIndexPath:indexPath animated:YES];

Unfortunately when I select the first row in the table view then my view in not displayed. When I debug I can see that it goes into the if statement, view controller is initialized and pushed onto the stack, but the view does not appear.

Any ideas? Thanks!

A: 

Sounds like the MyViewController.xib is not wired up correctly. Make sure that "File Owner" is set to the correct class and that it's view property connects to the view.

-pushViewController:animated: loads the view of the viewController provided to it but if there is no view it doesn't complain.

TechZen
Thanks for the suggestion. Indeed I did not have the view property associated with the view, but even now when it is connected the code does not work. Any other ideas?
Jakub
I checked and I can see that self.navigationControlleris nil. Any thoughts why it's nil? Should I set it up somehow?
Jakub
Solved! I didin't have any navigation controller used now when it's added, it's working perfectly. Thanks again for you input @TechZen!
Jakub