     }
 
     override init() {
+        width = 0; height = 0
         super.init()
-        setupForOrientation(UIApplication.sharedApplication().statusBarOrientation)
+        let size = self.collectionView?.bounds.size ?? UIScreen.mainScreen().bounds.size
+        transitionToOrientation(UIView.viewOrientationForSize(size), atSize: size)
     }
 
     required init(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
 
-    private func transistionToOrientation(orientation: UIInterfaceOrientation, atSize size: CGSize) {
+    private func transitionToOrientation(orientation: UIInterfaceOrientation, atSize size: CGSize) {
         setupForOrientation(orientation)
         height = size.height
         width = size.width

        return thumbnailRows * thumbnailCols
    }

    private lazy var width: CGFloat = { return self.collectionView?.frame.width ?? 0 }()

    private lazy var height: CGFloat? = {
        return self.collectionView?.frame.height
        }()

    // The width and height of the thumbnail here are the width and height of the tile itself, not the image inside the tile.
    private var thumbnailWidth: CGFloat {

    private func setupForOrientation(orientation: UIInterfaceOrientation) {
        if orientation.isLandscape {
            thumbnailCols = 5
        } else if UIScreen.mainScreen().traitCollection.userInterfaceIdiom == .Pad  {
            thumbnailCols = 4
        } else {
            thumbnailCols = 3
        }
    }

