I'm having some problems with a Navigation controller in my app. Moving from the RootViewController to a UITableViewController works fine. I now want to have one more level of drilldown, so users pick an item from the list and a new screen appears, like this:
RootViewController --> TableViewController --> ItemViewController
I've used the exact same code that switches the first views, but I get:
Application tried to push a nil view controller on target <UINavigationController...
The code is identical to the first one, so how can it be nil?
In RootViewController.h:
@interface RootViewController : UIViewController {
IBOutlet TableViewController *tableViewController;
}
@property (nonatomic, retain) TableViewController * tableViewController;
In the .m file I synthesize the property and then use a button to call:
[self.navigationController pushViewController:tableViewController animated:YES];
In TableViewController.h:
#import "ItemDetailViewController.h"
@class TableViewController;
@interface TableViewController : UITableViewController {
IBOutlet ItemDetailViewController * itemDetailViewController;
}
@property (nonatomic, retain) ItemDetailViewController * itemDetailViewController;
@end
And again, I synthesize it in the .m file and use code to push the new view in didSelectRowAtIndexPath:
[self.navigationController pushViewController:itemDetailViewController animated:YES];
When you tap on an item I get the error message above. Does anyone have any idea why this is happening?