Reputation: 5823
I created a view controller and then create a navigation controller with:
initWithRootViewController:
then I observed that it calls pushViewController:animated:
, since I am using my own UINavigationController
subclass, I overwrite pushViewController:animated:
:
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[super pushViewController:viewController animated:animated];
// do something with the VC
}
The problem is, immediately after
[super pushViewController:viewController animated:animated];
the viewController.isViewLoaded
is NO, so I cannot actually do what I want, is there a way to force a VC to be loaded, when it is used as the root VC of a navigation controller?
Thanks!
edit, below is the code:
MyViewController *vc = [[MyViewController alloc] initWithNib:@"" bundle:nil];
MyNavController *nav = [[MyNavController alloc] initWithRootViewController:vc];
self.revealViewController.frontViewController = nav;
Upvotes: 0
Views: 275
Reputation: 4805
Access view before pushing viewController.
[viewController view];//this will load your view
[super pushViewController:viewController animated:animated];
Upvotes: 1
Reputation: 148
I found this answer in the Apple documentation
The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This class is not intended for subclassing.
Upvotes: 1