I have a view controller and I want to implement a navigation controller inside it, but when I implemented it through Interface Builder or programmatically it doesn’t work.
Most of it I implemented through Interface Builder, but here is the code I implemented in the AppDelegate, and which I am trying to implement in my view controller.
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:navController.view];
I know I can’t implement “window” in a view controller so I tried this in my view controller:
[self.view addSubview:navController];
But it still doesn’t work.
In the app delegate’s applicationDidFinishLaunching you have to add this code.
where viewController is the object of the myViewController class to which u need to add the navigation controller. It s declared in the header file of appDelegate.Similarly the navigationController is also declared in tat. Hope this helps.
New code: