title: How to use collection view buttons to select view controllers in swift
body: <p>I have a CollectionViewController with 3 buttons populated. The view works well, but how do I select different view controllers based on the button selected? I added the button as an action, but I don't know how to specify which button is selected so I can send the user to different viewcontrollers.</p>
  
  <pre><code>import UIKit
  
  private let reuseIdentifier = "Cell"
  
  class CollectionViewController: UICollectionViewController {
  
  var imageArray = [UIImage(named: "tempOwl.png"), UIImage(named: "tempPuzzle.png"), UIImage(named: "tempHouse.png")]
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      self.clearsSelectionOnViewWillAppear = false
      self.collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
  
  }
  
  @IBAction func menuButton(sender: UIButton) {
      let controller = storyboard?.instantiateViewControllerWithIdentifier("myHome")
      presentViewController(controller!, animated: true, completion: nil)
  
  }
  
  override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -&gt; Int {
      return 1
  }
  
  override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 3
  }
  
  override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
  
      let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as UICollectionViewCell
      let imageView = cell.viewWithTag(1) as! UIButton
      imageView.setBackgroundImage(self.imageArray[indexPath.row], forState: .Normal)
  
      return cell
  }
  }
  </code></pre>