Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2030470
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类:

2010-04-22 10:38:35

  1. Introduce
    Navigation controller is implemented as class UINavigationController. It is used to build hierarchical applications, it manages a group of view controllers as a stack.
    UINavigationController contains 3 parts, UINavigationBar, UIViewController, and UIToolBar.
    Navigation controller usually is used with UITableView.
  2. View Controllers in Navigation Controllers
    1. Root View Controller
      It is the first view controller the navigation controller pushes onto its stack, so it is the bottommost view controller in the view hierarchy.
    2. Sub View Controllers
      To drill down into a sub view from root view, jsut create a new sub view controller and push it onto the navigation controller.
  3. How to Create Navigation Controller
    1. Define Root View Controller
      Define a class inherits from UIViewController or UITableViewController
    2. Define Sub View Controllers
      Define classes inherit from UIViewController or UITableViewController
    3. Create Navigation Controller
      1. Where To Create Navigation Controller
        A -> B -> C/D/E/F, if B is root view controller, and C,D,E,F are sub view controllers, you must define a field of type (UINavigationController *) in class A, and create its intance in A;
        a -> b/c/d/e/f, if a is root view controller, and b,c,d,e,f are sub view controllers, you must define a field of type (UINavigationController *) in subclass of UIApplicationDalegate
      2. How to Create Root View Controller
        You can create Navigation Controller in code,
        and you can also create it in Nib. If you create navigation controller in Nib file, just expand navigation controller icon, and single click View Controller icon under navigation controller, then press Command-4 to bring up identity inspector, change the underlying class to the class name of root view controller.
      3. ...
    4. Show Root View
      If you create Navigation Controller in code, when you display root view, you must create an instance of root view controller, then call UINavigationController:pushViewController:animated: to push it onto navigation controller, finally, call [window addSubview: navController.view] (Here, window is instance of UIWindow, and navController is instance of UINavigationController) to show root view.
      If you create navigation controller in Nib, and have set underlying class of navigation controller to root view controller, here just call [window addSubview: navController.view] to show root view.
    5. Show Sub View
      Call UINavigationController:pushViewController:animated: to add sub view on root view or other sub view.
    6. Popup View
      If Back button on navigation controller is press, the sub view controller is poped, and previous view is show, ou can manual to pop current sub view by calling UINavigationController:popViewControllerAnimated:.
    7. ...
  4. Advanced
    More details about navigation controller, please refer to http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html
  5. ...

Reference
  1. Beginning iPhone Development: Exploring the iPhone SDK
    Chapter: Application Settings and User Defaults
    Page: P231~301

阅读(1036) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~