开发者

Good way to have ViewControllers accessing NavigationController?

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜