             self?.updateLayoutsForCurrentOrientation()
         }) {
             [weak self] _ in
-            self?.lastUsedOrientation = UIApplication.sharedApplication().statusBarOrientation
+            self?.lastUsedOrientation = UIDeviceOrientation(rawValue: UIApplication.sharedApplication().statusBarOrientation.rawValue)
         }
     }
 


    func orientationDidChange() {
        let orientation = UIDevice.currentDevice().orientation
        let landscapeToLandscape = UIDeviceOrientationIsLandscape(orientation) && UIInterfaceOrientationIsLandscape(lastUsedOrientation)
        let portraitToPortrait = UIDeviceOrientationIsPortrait(orientation) && UIInterfaceOrientationIsLandscape(lastUsedOrientation)
        if landscapeToLandscape || portraitToPortrait {
            let newOrientation = UIInterfaceOrientation(rawValue: orientation.rawValue)
            if newOrientation == lastUsedOrientation {
                return
            }
            lastUsedOrientation = newOrientation!
            UIView.animateWithDuration(0.6) {
                [weak self] in
                self?.updateLayoutsForCurrentOrientation()

        view.addSubview(spinner)
    }

    private var lastUsedOrientation: UIDeviceOrientation!

    public override func viewWillAppear(animated: Bool) {
        lastUsedOrientation = UIDeviceOrientation(rawValue: UIApplication.sharedApplication().statusBarOrientation.rawValue)
    }

    private var initialOrientation: UIDeviceOrientation!

    public func showFrom(viewController: UIViewController) {
        backgroundSnapshot = UIApplication.sharedApplication().delegate?.window??.rootViewController?.view.snapshot()

        view.userInteractionEnabled = false
        initialOrientation = UIDeviceOrientation(rawValue: UIApplication.sharedApplication().statusBarOrientation.rawValue)
    
        dispatch_async(dispatch_get_main_queue()) {
            self.collectionView.alpha = 0
