title: iOS - Adding controls on top of AVPlayerViewController
body: <p>I have a subclass of AVPlayerViewController that I want to add my custom controls on it. I successfully added my custom controls on top of the AVPlayerViewController. However, these controls are only responsive for a short time. After a few seconds, clicking any of the button won't trigger the touchUpInside event.</p>
  <p>Below is the code I'm using:</p>
  <pre><code>class LSPlayerViewController : AVPlayerViewController {
  
  private var btnPlay : UIButton!
  
  func addControls() {
      self.showsPlaybackControls = false
      
      //PLAY BUTTON
      let btnPlayRect = CGRect(x: 0, y: 0, width: 19, height: 25)
      btnPlay = UIButton(frame: btnPlayRect)
      btnPlay.center = self.view.center
      btnPlay.setImage(#imageLiteral(resourceName: &quot;PauseIcon&quot;), for: .normal)
      btnPlay.addTarget(self, action: #selector(self.playButtonTapped(sender:)), for: .touchUpInside)
      btnPlay.alpha = 0
      btnPlay.isUserInteractionEnabled = true
      self.view.addSubview(btnPlay)
  }
  
  func playButtonTapped(sender: UIButton!) {
      if sender.isPlayIconOn == true {
          sender.setImage(#imageLiteral(resourceName: &quot;PauseIcon&quot;), for: .normal)
          self.player?.play()
      } else {
          sender.setImage(#imageLiteral(resourceName: &quot;PlayIcon&quot;), for: .normal)
          self.player?.pause()
      }
  }
  </code></pre>