UICollectionView example in Swift

In this video tutorial I am going to share with you how to create and use UICollectionView in Swift. Here is what we are going to cover:

  • Create a new UIViewController with UICollectionView
  • Implement custom UICollectionViewCell
  • Load list of images by calling a server side PHP script which will return a JSON array of images
  • Display images in UIScrollView
  • When user taps on an image, open image in a separate view controller

If you are interested to learn how to implement features User Sign up, Sign in, Password reset, Email verification, Profile details update together with Left Side Sliding Navigation menu and other features with Swift and Parse SDK for iOS, please check out my video course which will guide you through implementation of these features step by step and will save you a lot of time 🙂 https://goo.gl/xlbQsf

Download Swift source code of this project

PHP script that returns list of images:

 header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
 header("Cache-Control: post-check=0, pre-check=0", false);
 header("Pragma: no-cache");

 $images = array();
 
 $images[] = "http://swiftdeveloperblog.com/wp-content/uploads/2015/07/1.jpeg";
 $images[] = "http://swiftdeveloperblog.com/wp-content/uploads/2015/07/2.jpeg";
 $images[] = "http://swiftdeveloperblog.com/wp-content/uploads/2015/07/3.jpeg";
 $images[] = "http://swiftdeveloperblog.com/wp-content/uploads/2015/07/4_1.jpeg";
 $images[] = "http://swiftdeveloperblog.com/wp-content/uploads/2015/07/5.jpeg";
 $images[] = "http://swiftdeveloperblog.com/wp-content/uploads/2015/07/6.jpeg";
 
 echo json_encode($images);