Connecting the section header's label to ExploreViewController

To be able to display the selected city in ExploreHeaderView, you need to connect the outlet of the subtitle label to a property in ExploreHeaderView. Perform the following steps:

  1. In the document outline, click the label for the Explore Header View that has the text PLEASE SELECT A LOCATION:

  1. Click the Adjust Editor Options button and choose Assistant. An assistant editor appears on the right side of the screen. Make sure that it's showing the contents of ExploreHeaderView.swift.
  2. Ctrl + Drag from the label to the space between the curly braces:


  1.  In the box that appears, set the name to lblLocation and click Connect.
  2. The lblLocation outlet has been created in ExploreHeaderView. Close the assistant editor by clicking the x button.
  3. Click ExploreViewController.swift in the Project navigator. Add the following property declaration just below the manager declaration to store the location passed to ExploreViewController by LocationViewController:
var selectedCity:LocationItem?
  1. Just after the selectedCity property declaration, type the following:
var headerView:ExploreHeaderView!

This property will contain a link to ExploreHeaderView and allow ExploreViewController to set the value for lblLocation.

Next, let's configure the Done button in the Locations screen so that, when it is tapped, the Explore screen will appear with the selected city displayed in the collection view section header. You will do this in the next section.

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

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