Advantages & disadvantages of using UICollectionView in Swift

Henry Chan
Feb 23, 2017 · 2 min read

Ever since the first day I learned Swift, I have always used UITableView throughout my application. I find that UITableView was very simple to implement, so I did not bother to use UICollectionView. However after I have done some research, I find that UICollectionView was just as easy to implement and has many more capabilities than UITableView. In fact, UICollectionView can do almost anything that UITableView offers. Let’s talk about some advantages of UICollectionView:

Advantages

  • Allows customizable layout that can be very complex(example: different sizing of each cell)
  • Supports multiple cells in one row
  • Provides horizontal scroll direction, eliminates the need to create scroll view to achieve the same effect
  • Supports custom animations for cells based on layout
  • Can implement drag and drop functionality
  • More options for headers and footers settings, it does not need to be anchored on the top or bottom
  • Does not include blank cells

Disadvantage

I haven’t found a lot of disadvantages using UICollectionView. UICollectionView encapsulates almost all of UITableView capabilities, however I want to point out that autoresizing cells in UICollectionView can be a challenge. In UITableView, we can easily achieve autoresizing cells by returning the automatic dimensions for it’s height. As for UICollectionView, it can be a complex problem to solve.

Personally I have grown to love UICollectionView. I started to implement UICollectionView in almost all of my projects. If you have to ask me, I would choose UICollectionView over UITableView any day. However if you want to implement a project that is very simple, then I would choose UITableView, but if you choose to use a complex layout, then my choice is UICollectionView. I will continue to learn, and reap the benefits of UICollectionView.


Thanks for tuning in! 😎

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade