title: Why UITapGestureRecognizer does not work if we make it become the member variable of a class?
body: <p>I was wondering, why <code>UITapGestureRecognizer</code> doesn't work, if we make it become the member variable of a class?</p>
  <h2>Not working. hideKeyboard is not called when tapped</h2>
  <pre><code>class TabInfoSettingsCell: UICollectionViewCell {
      
      private let hideKeyboardTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))
  
      override func awakeFromNib() {
          super.awakeFromNib()
          
          self.isUserInteractionEnabled = true
          self.addGestureRecognizer(hideKeyboardTapGestureRecognizer)
      }
  
      @objc private func hideKeyboard() {
          print(&quot;hide keyboard&quot;)
      }
  </code></pre>
  <hr />
  <h2>Working</h2>
  <pre><code>class TabInfoSettingsCell: UICollectionViewCell {
      
      override func awakeFromNib() {
          super.awakeFromNib()
          
          self.isUserInteractionEnabled = true
          let hideKeyboardTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))
          self.addGestureRecognizer(hideKeyboardTapGestureRecognizer)
      }
  
      @objc private func hideKeyboard() {
          print(&quot;hide keyboard&quot;)
      }
  </code></pre>
  <hr />
  <p>Do you have idea what is the reason behind, on why <code>UITapGestureRecognizer</code> does not work if we make it become the member variable of a class?</p>