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