首页 > 代码库 > Chapter 10 UINavigationController

Chapter 10 UINavigationController

 Chapter 10 UINavigationController

1. When your application presents multiple screens of information, a UINavigationController maintains a stack of those screens. Each screen is the view of a UIViewController, and the stack is an array of view controllers. When a UIViewController is on top of the stack, its view is visible.

 

2. The viewControllers array of a navigation controller is dynamic - you start with a root view controller and push view controllers depending on user input, when the stack is popped, the controller is destroyed.  pushViewController:animated:

 

3. When the message endEditing: is sent to a view, if it or any of its subviews is currently the first responder, it will resign its first responder status, and the keyboard will be dismissed. (The argument passed determines whether the first responder should be forced into retirement. Some first responders might refuse to resign, and passing YES ignores that refusal.)

 

4. Like UINavigationItem, UIBarButtonItem is not a subclass of UIView. Instead, UINavigationItem encapsulates information that UINavigationBar uses to configure itself. Similarly, UIBarButtonItem is not a view, but holds the information about how a single button on the UINavigationBar should be displayed. (A UIToolBar also uses instances of UIBarButtonItem to configure itself.)

 

5. UIViewController has an editButtonItem property, and when sent editButtonItem, the view controller creates a UIBarButtonItem with the title Edit. Even better, this button comes with a target-action pair: it sends the message setEditing:animated: to its UIViewController when tapped.

 

6. Dismiss keyboard  with UIResponder’s method:

 

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    [self.view endEditing:YES];

}

 

 

 

 

Chapter 10 UINavigationController