concept navigation bar in category ios

This is an excerpt from Manning's book iOS Development with Swift.
Table 1.5. Storyboard elements
Element
Description
View controller Manager for a scene’s views. View Visual components of your interface. Safe area An area of the root view that you can be confident is not obstructed by special views such as navigation bars. You can use safe area layout guides to help you lay out your views. (More on the safe area when we discuss auto layout in chapter 5.) Constraint Rules that define the layout of the views in a scene. (We’ll discuss constraints more in chapter 5, too.) Gesture recognizers Helpers that detect common gestures. (We’ll come back to these when we discuss user interaction in chapter 4.) First responder A first responder is the view in your scene that will be the first to receive any app events. Tapping on a text field, for example, will make it first responder. Use the first responder icon in Interface Builder to connect an action from a control to an action on the current first responder. Exit Customize behavior when exiting a scene. We’ll explore this further when we learn about navigation in chapter 9. Storyboard entry point Indicates the initial scene for the storyboard.
A navigation controller manages navigation going forward and back through a hierarchy of content view controllers. The navigation controller is usually used in conjunction with a navigation bar. The navigation bar can be helpful to orient the user with a title for the scene and a back button to return to the previous scene. The navigation bar can also be a useful location for additional buttons—a great place for the add button!
In the viewDidLoad method, the BookViewController should check if the book object exists, and if it does, prefill the fields. If a book object exists, you know that you’re editing rather than creating a book. Take the opportunity to adjust the navigation bar’s title accordingly. Be sure to fill the fields before checking if the Save button should be enabled. if let book = book { 1 bookCover.image = book.cover 2 titleTextField.text = book.title 2 authorTextField.text = book.author 2 isbnTextField.text = book.isbn 2 notesTextView.text = book.notes 2 navigationItem.title = "Edit book" 3 } saveButton.isEnabled = !titleTextField.text!.isEmpty 4
- 1 Unwraps book object
- 2 Prefills form fields with book
- 3 Changes navigation bar title
- 4 Disables Save button if no title
A Cancel button and a Save button would be perfect for exiting the book detail view controller, and the best place for these buttons is on a navigation bar (see figure 9.18).
To give the book detail view controller a navigation bar for the Save and Cancel buttons, embed it in its own navigation controller.

This is an excerpt from Manning's book Anyone Can Create an App: Beginning iPhone and iPad programming.
The navigation bar is the bar at the top of the panel with the buttons on it.
Add a navigation bar to the second scene, and add a Cancel button.
In order to return to the initial scene in your app, you’ll add a navigation bar to the top of the app. If you open your Phone app on your iPhone, you’ll notice the bar at the top that displays the title of the scene you’re on (Favorites, Contacts, Voicemail) as well as buttons to the left and right of the title on some scenes. For instance, on the Favorites scene, you have the Edit button on one side of the title and the add (+) button on the other. This bar, called a navigation bar, serves several purposes. The title clearly tells the user which scene they’re on, which is a nice navigational aid so they don’t get lost in the app. The navigation bar also provides an area to add buttons such as Back, Cancel, Edit, and Add. You’ll add a navigation bar to the second scene now so you can let the user go back to the first scene.
In Xcode, search the Object Library for navigation. You’ll notice that several items are returned, including Navigation Controller, navigation bar, and navigation item. In this case, you want the navigation bar. Grab the navigation bar and drag it to the top of the second scene so it looks like figure 12.4.
Now double-click the title in the navigation bar and change it to Second Screen. Run the app again in the Simulator, and you should see the Second Screen title in the navigation bar when you click the Push Me button. Next, you can add a Cancel (or Done) button the navigation bar so the user can return to the previous scene. In general, you want to use a Cancel button when there’s something that the user was doing that they want to cancel out of (for instance, adding a new contact to the address book). You want to use a Done button when the user is finished with an action.
Your first inclination may be to look at the Object Library and add a navigation item to the bar, and that would seem logical—but in this case, it isn’t what you need. Search the Object Library again for a button. Grab the object Bar Button Item, and drag it up to the left side of the navigation bar. Once you drop it on the bar, it should say Item on the button, as shown in figure 12.5.