Photo Gallery with UICollectionView

UICollectionView of Awesomeness

I’m just going to say it. UICollectionView is the coolest, most useful addition that shipped with iOS6. The obvious solution to use this for is a grid layout, but that is just the tip of the iceberg. You can transform your views to use a circular layout or cover flow style layout, etc. They are extremely configurable, flexible and extensible.

UICollectionView and UICollectionViewController are the perfect balance between UITableView, UITableViewController, UIScrollView and UIPageController.

There are just as many “photo gallery” libraries out there as there apps that use them. Unforunately, I never found one that I was really happy with. I’ve developed a few of my own, but I wasn’t helped with them either. At times they were too complicated and others they weren’t extensive enough.

UICollectionView of awesomeness to the rescue.

For an great introduction to UICollectionView go and checkout this tutorial on Ray Wenderlich’s site.

Recreating iPhone Photo App

The Introducing Collection Views session at last year’s WWDC was absolutely amazing and really showed the infinite possibilities of using UICollectionView to showcase data in fascinating ways. In my opinion, there is no better way to learn something than to actual use it. So I set out to recreate the native iPhone photos app.

Aside from dealing with some of the headaches with the AssetsLibrary library, laying out a grid and the pagination of the large images was elementary. Though this a very simplicstic example I think it demonstrates how quick and efficient these new classes provide. I’ve used this same project as the basis for loading in remote photo datasources and works just as beautifully.

Bryan Hansen has a great tutorial a custom gallery as well.

CWPhotoViewer on Github