title: How do I get a UIButton press to work in a UICollectionViewCell in Swift?
body: <p>So this is a tvOS project in Swift. I have a custom UICollectionViewCell with a button as one of its subviews. I add a target to the button to allow it to interpret clicks. Here's a simplified version of the relevant code</p>
  
  <pre><code>class CustomCell: UICollectionViewCell {
      var button:UIButton!
  
      override init(frame: CGRect) {
          super.init(frame: frame)
  
          button = UIButton(...) // Button is initialized with a frame
          button.userInteractionEnabled = true
          button.enabled = true
          button.addTarget(self, action: "pressed:", forControlEvents: .PrimaryActionTriggered)
          contentView.addSubview(button)
      }
  
      func pressed(sender: UIButton!) {
          print("button pressed!")
      }
  }
  </code></pre>
  
  <p>For some reason it's not ever printing out my message. I tried adding 'pressedEnded' to the cell class to see if it's getting any and it gets called</p>
  
  <pre><code>func pressesEnded(presses: Set&lt;UIPress&gt;, withEvent event: UIPressesEvent?) {
          // If I put a breakpoint here it's reached
  }
  </code></pre>
  
  <p>Any suggestions? When I run it in the simulator the button can get focus, so I don't know why it can't get any events</p>