         }
 
         NSNotificationCenter.defaultCenter().addObserverForName(UIDeviceOrientationDidChangeNotification, object: nil, queue: nil) { (NSNotification) -> Void in
-            let deviceOrientation = UIDevice.currentDevice().orientation
-            switch deviceOrientation {
+            switch UIDevice.currentDevice().orientation {
             case .FaceDown, .FaceUp, .Unknown:
                 ()
             case .LandscapeLeft:
-                self.widgetOrientation = .LandscapeLeft
+                self.updateWidgetsToOrientation(.LandscapeLeft)
             case .LandscapeRight:
-                self.widgetOrientation = .LandscapeRight
+                self.updateWidgetsToOrientation(.LandscapeRight)
             case .Portrait:
-                self.widgetOrientation = .Portrait
+                self.updateWidgetsToOrientation(.Portrait)
             case .PortraitUpsideDown:
-                self.widgetOrientation = .PortraitUpsideDown
-            }
-            self.updateWidgetsToOrientation(self.widgetOrientation)
+                self.updateWidgetsToOrientation(.PortraitUpsideDown)
+            }
         }
     }
 

        } else {
            cell = collectionView.dequeueReusableCellWithReuseIdentifier(PhotoCollectionViewCell.cellIdentifier(), forIndexPath: indexPath) as! PhotoCollectionViewCell
        }

        if widgetOrientation == .LandscapeLeft {
            cell.contentView.transform = CGAffineTransformMakeRotation(CGFloat(M_PI/2))
        } else if widgetOrientation == .LandscapeRight {
            cell.contentView.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI/2))
        } else {
            cell.contentView.transform = CGAffineTransformMakeRotation(0)
        }

        cell.delegate = self
        return cell
    }

        delegate?.photoCaptureViewController(self, didSelectAssetAtIndexPath: indexPath)
    }
}


extension UIView {
    public func rotateToDeviceOrientation() {
        switch UIDevice.currentDevice().orientation {
        case .FaceDown, .FaceUp, .Unknown:
            ()
        case .LandscapeLeft:
            self.transform = CGAffineTransformMakeRotation(CGFloat(M_PI/2))
        case .LandscapeRight:
            self.transform = CGAffineTransformMakeRotation(CGFloat(-M_PI/2))
        case .Portrait, .PortraitUpsideDown:
            self.transform = CGAffineTransformMakeRotation(0)
        }
    }
}
