         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)
+        }
+    }
+}

        }

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


        } else {
            cell = collectionView.dequeueReusableCellWithReuseIdentifier(PhotoCollectionViewCell.cellIdentifier(), forIndexPath: indexPath) as! PhotoCollectionViewCell
        }
        cell.contentView.rotateToDeviceOrientation()
        cell.delegate = self
        return cell
    }
