 
     if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft
       || UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight {
-        //deviceDidRotate()
+        deviceDidRotate()
     }
   }
 


  func deviceDidRotate() {
    var transform = CGAffineTransformIdentity

    if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeLeft {
      transform = CGAffineTransformMakeRotation(1.57)
      //view.removeConstraints(collectionView.constraints())
      collectionSize = CGSizeMake(view.frame.height, view.frame.width)
      view.removeConstraint(collectionViewRight!)
      view.removeConstraint(collectionViewTop!)
      view.removeConstraint(collectionViewHeight!)
      view.removeConstraint(collectionViewWidth!)

      collectionViewRight = NSLayoutConstraint(item: collectionView, attribute: .Top,
        relatedBy: .Equal, toItem: view, attribute: .Top,
        multiplier: 1, constant: 0)

      collectionViewTop = NSLayoutConstraint(item: collectionView, attribute: .Right,
        relatedBy: .Equal, toItem: view, attribute: .Right,
        multiplier: 1, constant: 0)

      collectionViewHeight = NSLayoutConstraint(item: collectionView, attribute: .Width,
        relatedBy: .Equal, toItem: view, attribute: .Width,
        multiplier: 1, constant: 0)

      collectionViewWidth = NSLayoutConstraint(item: collectionView, attribute: .Height,
        relatedBy: .Equal, toItem: view, attribute: .Height,
        multiplier: 1, constant: 0)
      view.addConstraint(collectionViewRight!)
      view.addConstraint(collectionViewTop!)
      view.addConstraint(collectionViewHeight!)
      view.addConstraint(collectionViewWidth!)

      collectionView.transform = CGAffineTransformMakeRotation(1.57)

    } else if UIDevice.currentDevice().orientation == UIDeviceOrientation.LandscapeRight {
      transform = CGAffineTransformMakeRotation(-1.57)

    }

    let indexPath = NSIndexPath(forRow: 0, inSection: 0)
    collectionView.reloadItemsAtIndexPaths([indexPath])
  }

  // MARK: - Autolayout

  func setupConstraints() {
    collectionViewRight = NSLayoutConstraint(item: collectionView, attribute: .CenterX,
      relatedBy: .Equal, toItem: view, attribute: .CenterX,
      multiplier: 1, constant: 0)

    collectionViewTop = NSLayoutConstraint(item: collectionView, attribute: .CenterY,
      relatedBy: .Equal, toItem: view, attribute: .CenterY,
      multiplier: 1, constant: 0)

    collectionViewHeight = NSLayoutConstraint(item: collectionView, attribute: .Height,
      relatedBy: .Equal, toItem: view, attribute: .Width,
      multiplier: 1, constant: 0)

    collectionViewWidth = NSLayoutConstraint(item: collectionView, attribute: .Width,
      relatedBy: .Equal, toItem: view, attribute: .Height,
      multiplier: 1, constant: 0)
    view.addConstraint(collectionViewRight!)
    view.addConstraint(collectionViewTop!)
    view.addConstraint(collectionViewHeight!)
    view.addConstraint(collectionViewWidth!)
    collectionView.backgroundColor = UIColor.redColor()
    collectionView.transform = CGAffineTransformMakeRotation(1.57)
    
    view.addConstraint(NSLayoutConstraint(item: pageLabel, attribute: .Leading,
      relatedBy: .Equal, toItem: view, attribute: .Leading,

      collectionViewLayout: self.collectionViewLayout)

    collectionView.setTranslatesAutoresizingMaskIntoConstraints(false)
    collectionView.backgroundColor = .blackColor()
    collectionView.dataSource = self
    collectionView.delegate = self
    collectionView.decelerationRate = UIScrollViewDecelerationRateFast
