控制UINavigationController跳转的方法

2010年2月9日 | laifangwen

原作者:Lin

After a lot of trial and mistakes, finally I kinda figured out how to make UINavigationController work…
1. initialise
To initialise:
1.1. with a default root controller:
self.controller = [mainController getInstance]; 
self.nav = [[UINavigationController alloc] 
initWithRootViewController:self.controller];
1.2. without a default root controller
self.nav = [[UINavigationController alloc] init];
2. push in a view
self.controller = [view1Controller getInstance];
[self.nav 
pushViewController: self.controller 
animated:YES];
NOTE: do NOT release self.controller here, as the nav controller will release it when it needs to do so, already tested - the pop view method will release it.
NOTE 2: I am using a getInstance function here to ensure each new controller is a singleton, otherwise, each time a new object is instantiated and taken one memory space.
3. pop out a view and go back a level
simply:
[self.nav popViewControllerAnimated:YES]
4. Go back to top level
[self.nav popToRootViewControllerAnimated: YES];
5. go to any level you like
Theoritically, this should be as simple as UINavigationController::pushViewController(controller instance), but it’s not yet tested
Now, to get the nav controller from within the controllers pushed to the nav controller stack, simly go
[thePushedInController navigationController];
To get an array of all controllers loaded into the nav controller:
[nav controllers];

Tags: UINavigationController  手机  程序  cocoa  object-c  
相关文章:

怎样为Grouped UITableView增加一个好看的背景  (2010-2-9 11:0:58)

iPhone程序开发的视图和控制器的层次图  (2010-2-9 10:55:37)

自定义NavigationBar的backBarButtonItem  (2010-2-9 10:46:36)

emLog的图片水印插件  (2010-1-8 15:1:59)

php正则表达式教程及使用说明  (2010-1-8 11:48:38)

iPhone开发之重力感应实例代码类  (2009-12-30 13:53:20)

分享一个应用iPhone重力感应器程序源代码  (2009-12-30 13:22:43)

【分享】V2EX安装方法说明:project-babel-v0.6安装步骤  (2009-12-30 10:2:34)

【翻译】在iPhone上使用UITableView开发九宫格视图  (2009-12-28 13:9:16)

【分享】iPhone开发之数据保存  (2009-12-26 10:28:23)

引用通告地址: http://blog.laifangwen.com/cmd.asp?act=gettburl&id=270

评论: 0 | 引用: 0 | 浏览:
名称(*):
邮箱:
网站链接:
正文(*):
选 项:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。