Exploring controllers and classes

So far, you have implemented view controller scenes in Main.storyboard using Interface Builder. You added ExploreViewController, a UIViewController subclass to manage the collection view inside the Explore screen, and RestaurantListViewControllera UIViewController subclass subclass to manage the collection view inside the Restaurant List screen. However, you still haven't learned how the code you added to each of them works. 

A collection view displays an ordered collection of collection view cells using customizable layouts.

To learn more about collection views, you can refer to https://developer.apple.com/documentation/uikit/uicollectionview.

The layout for the collection view is dictated by UICollectionViewFlowLayout.

To learn more about UICollectionViewFlowLayoutyou can refer to https://developer.apple.com/documentation/uikit/uicollectionviewflowlayout.

The data displayed by a collection view is normally provided by a view controller. A view controller  providing data for a collection view must conform to the UICollectionViewDataSource protocol. This protocol declares a list of methods that tells the collection view how many cells to display and what to display in each cell. It also covers the creation and configuration of  supplementary views (such as the collection view section header).

To learn more about the UICollectionViewDataSource protocol, you can refer to https://developer.apple.com/documentation/uikit/uicollectionviewdatasource.

To provide user interaction, a view controller for a collection view must also conform to the UICollectionViewDelegate protocol, which declares a list of methods which are triggered when a user interacts with the collection view.

To learn more about the UICollectionViewDelegate protocol, you can refer to https://developer.apple.com/documentation/uikit/uicollectionviewdelegate.

Let's see how this works by implementing a view controller for a collection view in a playground, which will display a collection view in the playground's live view, which acts as a display screen for the playground.

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

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