Implementing the Restaurant List screen

As can be seen in the app tour in Chapter 9, Setting Up the Basic Structure, once you've set a location and tapped a cuisine in the Explore screen, the Restaurant List screen will appear, showing a list of restaurants.

To implement the Restaurant List screen, you'll need to add a new view controller scene to your storyboard. You'll add a collection view to the view in this scene. To do this, you'll also add a new Cocoa Touch Class file containing the RestaurantListViewController class definition, make it the view controller for the view controller scene's view, and connect the outlets of the collection view to this class. This process is very similar to the one we followed in the previous chapter for ExploreViewController.

Let's start by adding the new view controller scene. Go through the following steps:

  1. In Main.storyboard, move the Navigation Controller Scene and View Controller Scene that you added in the previous chapter upward to make room for the new view controller scene that you will add:

  1. Click the Object library button and type view con into the filter field. A View Controller object will be in the results.
  1. Drag the View Controller object into the storyboard, as shown in the following screenshot:

  1. Click the Object library button and type colle into the filter field. A Collection View object will be in the results.
  1. Drag the Collection View object to the View in the View Controller scene:

  1. Make sure that the Collection View is selected. Then, click the Add New Constraints button:


  1. Type 0 into all the Spacing to nearest neighbor fields and make sure that the red struts are selected (they will turn bright red). Click the Add 4 Constraints button.
  1. The edges of Collection View are now bound to the edges of the View in the View Controller Scene:

The view controller scene for the Restaurant List screen has been added, but it does not have a view controller yet. In the next section, you'll add a new Cocoa Touch Class file to your app so that you can declare and define the RestaurantListViewController class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.131.238