IOS Study Notes 15-learning experience of UINavigationController

Source: Internet
Author: User

 


I. UINavigationBar


1. A navigator controls several view controllers;

2. A navigation controller contains a NavigationBar and a toolBar;

3. one button in UINavigationBar is UINavigationItem (only one)

4. UINavigationItem is not controlled by UINavigationBar, but not by UINavigationController. It is controlled by the current view controller;

 


2. toolBar:

PS: A UINavigationController has only one toolBar, which is controlled by the current view and not controlled by UINavigationController.

 

 

UIBarButtonItem * addBar = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemTrash target: self action: @ selector (button)];

UIBarButtonItem * editBar = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemEdit target: self action: @ selector (button)];

UIBarButtonItem * saveBar = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemSave target: self action: @ selector (button)];

UIBarButtonItem * titleBar = [[UIBarButtonItem alloc] initWithTitle: @ "titile" style: UIBarButtonItemStyleBordered target: self action: @ selector (button)];


// Set the spacing
UIBarButtonItem * filexBar = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target: self action: nil]; // equal distance

// Custom spacing
UIBarButtonItem * fixBar = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFixedSpace target: self action: nil];
FixBar. width = 5;


NSArray * itemArray = @ [addBar, fixBar, editBar, filexBar, saveBar, filexBar, titleBar];

[Self. navigationController setToolbarHidden: NO animated: YES];

 


// [Self. navigationController. toolbar setItems: itemArray animated: YES]; // incorrect syntax. The toolBar is only controlled by the current view.

 

[Self setToolbarItems: itemArray animated: YES]; // correct

 

 

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.