title: Horizontal scroll when rotate UIColectionView in swift
body: <p>I'm trying to build a <code>collectionView</code> in swift, I want that when the device is in portrait the <code>collectionView</code> scrolls vertically while when I rotate the device in landscape mode the <code>collectionView</code> scrolls horizontally. This is the <code>CollectionView</code> class: </p>
  
  <pre><code>class SceneBuilderVC: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource{
      @IBOutlet var collection: UICollectionView!
  
      override func viewDidLoad() {
         super.viewDidLoad()
      }
  
      override func shouldAutorotate() -&gt; Bool{
         return true
      }
  
      override func supportedInterfaceOrientations() -&gt; Int{
          return Int(UIInterfaceOrientationMask.All.toRaw())
      }
  
      func numberOfSectionsInCollectionView(collectionView: UICollectionView!) -&gt; Int {
          return 1;
      }
  
      func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -&gt; Int {
             return 50;
      }
  
      func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -&gt; UICollectionViewCell!{
          var cell:UICollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as UICollectionViewCell
          cell.backgroundColor = UIColor.redColor()
          return cell
      }
  }
  </code></pre>
  
  <p>To change the scroll direction I need to change the <code>collectionView</code> layout.</p>
  
  <pre><code>var flowLayout:UICollectionViewFlowLayout = UICollectionViewFlowLayout()
  var scrollDirection = UICollectionViewScrollDirection.Vertical
  flowLayout.scrollDirection = scrollDirection
  self.collection.collectionViewLayout = flowLayout
  </code></pre>
  
  <p>Also, with iOS8, Apple change the screen rotating method <strong><code>willRotateToInterfaceOrientation:duration</code></strong> with <strong><code>viewWillTransitionToSize:withTransitionCoordinator</code></strong></p>
  
  <p>How can I use the **<code>viewWillTransitionToSize:withTransitionCoordinator</code>* method to check when the device rotate and as a consequence changing the scroll direction?</p>