> For the complete documentation index, see [llms.txt](https://ios-course.cornellappdev.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ios-course.cornellappdev.com/resources/textbook/uicollectionview/what-is-a-uicollectionview.md).

# What is a UICollectionView?

Fall 2023 | Vin Bui

### What is a UICollectionView?

Similar to a `UITableView`, a `UICollectionView` is a sub-class of `UIScrollView`. In other words, it is also a scrollable view. However, **a collection view is more dynamic and customizable than a table view.** A collection view still contains sections, but instead of rows in a table view, it uses items. Each **item** is represented by a `UICollectionViewCell` and can be displayed in a **grid-like** manner. Additionally, a `UICollectionView` also supports horizontal scrolling.

### Examples of a UICollectionView

<div><figure><img src="https://1509678725-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lwk7443W4ukbAF9S07e%2Fuploads%2FsLTk3JvGCK664g9gVEY7%2FUntitled.jpeg?alt=media&amp;token=682f01ed-3e70-438c-ad37-5ae8f5005e61" alt="" width="375"><figcaption><p>Instagram</p></figcaption></figure> <figure><img src="https://1509678725-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lwk7443W4ukbAF9S07e%2Fuploads%2FsCDMkE3SXsyCFYUZceId%2FUntitled.jpeg?alt=media&amp;token=0260808c-448a-4753-86bf-140393be1d57" alt="" width="375"><figcaption><p>Spotify</p></figcaption></figure></div>

### Breaking Down a UICollectionView

A `UICollectionView` contains **sections** where each section contains **items**, and each **item** being represented by a **cell**. If we look at the Spotify example above, we can see 3 sections, each having its own header. For example, the top section has the header “Made For vinnie”. Now, each section contains items, which are represented by a `UICollectionViewCell`. In each section, the square image is a `UICollectionViewCell`. If you have used Spotify before, then you know that these sections are horizontally scrolled.

As we can see, a `UICollectionView` is a lot more versatile and customizable than a `UITableView`. It allows for horizontally scrolling as well as laying items out in grid-like manner.
