title: Swift - Push to ViewController from UIButton in CollectionViewCell
body: <p>I am trying to make my button, when tapped, to push to a new View Controller. I've tried many different ways but it won't trigger the function that I have it linked to. I also checked the 3D stack view of my layers and the button is on top and clickable, even when I check the background color, it's not being covered by anything else.</p>
  
  <p>Does anyone have any ideas to what I am doing wrong?</p>
  
  <p>For now I am trying to make the button print out the sentence in the console, however whenever I press it, the string doesn't pop up, so I haven't bothered to connect it to the view controller yet.</p>
  
  <p>Also, I am coding this app without storyboards.</p>
  
  <p>Here is my code below.</p>
  
  <p>It is under the MainPageCell class declared as a UICollectionViewCell</p>
  
  <pre><code>private let playButton: UIButton = {
      let button = UIButton()
      button.setTitle("", for: .normal)
      button.backgroundColor = .clear
      button.translatesAutoresizingMaskIntoConstraints = false
      button.addTarget(self, action: #selector(MainPageCell.buttonTapped), for: .touchUpInside)
      return button
  }()
  
  @objc func buttonTapped() {
      print("I PRESSED THE BUTTON")
  }
  </code></pre>