Chapter 5. Using collection views
This chapter covers
- Using a collection view to display photos
- Implementing custom collection view cells
- Customizing collection view flow layouts
- Adding a collection view to your Albums app
When you created a table view for your Albums application, you used it to display a list of albums represented as rows. This worked well because you needed to display only an album’s thumbnail and its title beside it. One vital piece that it was missing was the ability to click an album and view all of the photos contained within it. The one thing you’ll need to display for each photo in the album is its thumbnail. You’ll use collection views to display all of the photos within a specific album. By using collection views, you’ll be able to put the thumbnails of each photo side by side using rows and columns.
Although you’ll be using a collection view to display photos in a grid, you’ll learn that they allow quite a bit of flexibility. You’ll be starting where you left off in the previous chapter so that you can finish your Albums application. Once you’ve finished, you’ll have a nice app that can allow you to view the albums and the photos you’ve stored on your phone, as shown in figure 5.1.
Figure 5.1. Our finished Albums application after we added a collection view to view photos within an album
