I am new to iPhone programming and I am programming a app that has a NavigationBar on top, and several successive ViewControllers.
I was wondering: how should I design such a thing? Clearly the ViewControllers need to have access to the NavigationController, but how? I have created a UINavManagedViewController that stores a reference to the navigationcontroller, and all viewcontrollers derive from that class.
@interface UINavManagedViewController : UIViewController {
UIManagingNavigationController *navManager;
}
@property (nonatomic, retain) UIManagingNavigationController *navManager;
@end
However, since this is clearly a thing that all programmers encounter, I was wondering about the default way to handle such a setup. My b开发者_开发百科eginner iPhone programming book didn't handle such cases.
Take a look at the UIViewController class reference. All UIViewControllers already have a navigationController
property which provides a reference to their parent navigation controller (if one exists).
精彩评论