Chapter 11
Working with Navigation View
Just build something that you'd want to use today, not something you think people would use somehow.
– Paul Graham
First things first, what is a navigation view? Similar to list views, navigation views are commonly used UI components in iOS apps. They offer a drill-down interface for presenting hierarchical content. Take a look at the pre-installed Photos app, YouTube, and Contacts. All of them utilize navigation views to display content in a hierarchical manner. Typically, you combine a navigation view with a stack of list views to create a sophisticated interface for your apps. However, it's important to note that you are not obligated to use both together. Navigation views can be employed alongside any type of view.
Creating Navigation Views
Let's head back to the FoodPin project and open the RestaurantListView.swift
file.
Hold the control key and click List
in RestaurantListView
. In the context menu, choose Embed.... Then change the default Container
to NavigationStack
. In iOS, you use NavigationStack
to create a navigation view.
To access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.