I created a Tab-based application in Xcode 4 using the “Tabbed Application template”.
In one of the view controllers, I have a Table View. Now when the user clicks on an item the table displays, I want a new view to appear.
I tried using:
[self.navigationController pushViewController:self.detailsViewController animated:YES];
but that doesn’t work. On further inspection, I found out that self.navigationController is null, so I guess I have to create it somewhere.
Could you point me to where would I create it?
I am guessing it would be in the Application Delegate’s applicationDidFinishLaunching method? Here’s how it currently looks (this has been generated automatically by Xcode):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
Thanks a lot for any help, I’ve been stuck on this for a while and I can’t seem to find out how to do this…
Your best bet would be to embed the view inside of a Navigation Controller. If your using the Storyboard, select the view (make sure it is outlined in blue) then go to Editor->Embed in Navigation Controller.
If you are doing it through code, then where you initially created this view, create a UINavigationController and initialize it with this view’s view controller.