title: Tap Gesture on tableViewCell Swift
body: <p>I would like to complete an action when the image in the table view cell is taped. I set a tap gesture through the storyboard but it reads the tap everytime the cell is touched.</p>
  
  <p>How can I Complete a tap gesture when only the image in my table view cell is taped?</p>
  
  <p><a href="https://i.stack.imgur.com/Mez3X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mez3X.png" alt="enter image description here"></a></p>
  
  <pre><code>  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return generalRoomDataArr.count // your number of cell here
      }
  
  
  
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
  
          let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
  
          //Transform Data From ^ to load at the bottom
          tableView.transform = CGAffineTransform (scaleX: 1,y: -1);
          cell?.contentView.transform = CGAffineTransform (scaleX: 1,y: -1);
          cell?.accessoryView?.transform = CGAffineTransform (scaleX: 1,y: -1);
  
          //Set username label to display username
          let usernameLabel = cell?.viewWithTag(1) as! UILabel
          usernameLabel.text = generalRoomDataArr[indexPath.row].username
  
  
          //Set message label to display message
          let messageLabel = cell?.viewWithTag(2) as! UILabel
          messageLabel.text = generalRoomDataArr[indexPath.row].message
          messageLabel.numberOfLines = 0
  
          //initialize UI Profile Image
          let imageView = cell?.viewWithTag(3) as! UIImageView
  
          //Make Porfile Image Cirlce
          imageView.layer.cornerRadius = imageView.frame.size.width/2
          imageView.clipsToBounds = true
  
          //Set timeStampLabel to current time AGO
          let timeStampLabel = cell?.viewWithTag(4) as! UILabel
          timeStampLabel.text = generalRoomDataArr[indexPath.row].timeStamp
          timeStampLabel.numberOfLines = 0
  
  
          //Loading and change of Usesrs profile image on chat cell
          let userProfileChatImage = generalRoomDataArr[indexPath.row].photoURL
  
          //Load profile image(on cell) with URL &amp; Alamofire Library
  
  
  
              let downloadURL = NSURL(string: userProfileChatImage!)
              imageView.af_setImage(withURL: downloadURL as! URL)
  
  
  
  
  
  
          // your cell coding
          return cell!
      }
  
  
  
  
  
  
      @IBAction func userPhotoTaped(_ sender: Any) {
  
          print("tapped")
      }
  
  
  
  
  
  
  
  
  }//END CLASS
  </code></pre>
  
  <p>I have also tried this </p>
  
  <pre><code>let tapped:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector(("TappedOnImage:")))
          tapped.numberOfTapsRequired = 1
          cell?.imageView?.addGestureRecognizer(tapped)
  
  func TappedOnImage(sender: UITapGestureRecognizer){
          print("Elltappy")
      }
  </code></pre>