title: Segue from UITableViewCell by tapping on an image inside of cell
body: <p>Been trying to figure this out for a while now and after a couple hours of searching for a solution I decided it was time to ask. </p>
  
  <p>I have a tableview that gets populated by custom UITableViewCells and currently when you tap on a cell it takes you to a detail view.</p>
  
  <p>Within the custom cell there is an image, I would like the user to be able to tap on that image and segue to a popover VC that shows the image.</p>
  
  <p>What I'm having trouble with is creating the segue when the image is tapped.</p>
  
  <p>In the file for the custom cell, I've set up a tap gesture recognizer on the image <strong><em>(pTap)</em></strong>:</p>
  
  <pre><code>override func awakeFromNib() {
      super.awakeFromNib()
  
      let tap = UITapGestureRecognizer(target: self, action: #selector(PostCell.voteTapped(_:)))
      let ptap = UITapGestureRecognizer(target: self, action: #selector(PostCell.imageTapped(_:)))
      tap.numberOfTapsRequired = 1
      ptap.numberOfTapsRequired = 1
      voteImage.addGestureRecognizer(tap)
      voteImage.userInteractionEnabled = true
      featuredImg.addGestureRecognizer(ptap)
      featuredImg.userInteractionEnabled = true
  
  
  }
  </code></pre>
  
  <p>I also have a function in the custom cell file for the tap:</p>
  
  <pre><code>func imageTapped(sender: UIGestureRecognizer) {
  
    print("image tapped")
  
  
  }
  </code></pre>
  
  <p>In my view controller file I've added a segue in did select row at index path:</p>
  
  <pre><code>func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
      let post: Post!
  
      if inSearchMode {
          post = filteredVenues[indexPath.row]
      } else {
  
          post = posts[indexPath.row]
      }
  
      print(post?.venueName)
  
      performSegueWithIdentifier("imageTapped", sender: nil)
  
  
  
      performSegueWithIdentifier("DetailsVC", sender: post)
  
  }
  </code></pre>
  
  <p>Also, in the storyboard I have created a segue from the VC that holds the tableview with the custom cells to the VC I'd like to show when the image is tapped. </p>
  
  <p>I've tried several different methods of getting this to work and haven't had any luck, the code you see above are what remains after my many failed attempts. I feel that the function for the tap in the custom cell file and the segue in the VC file are a part of the solution so that is why I have left them in.</p>
  
  <p>Any help would be appreciated. Thanks!</p>
  
  <p>Updates to code from answers below:</p>
  
  <p>Added protocol</p>
  
  <pre><code>protocol ImageSegueProtocol: class {
      func imageTapped(row: Int)
  }
  
  
  class PostCell: UITableViewCell {
  </code></pre>
  
  <p>Added IAB Func</p>
  
  <pre><code>@IBAction func imageTapped(sender: UIGestureRecognizer) {
     guard let row = row else { return }
      delegate?.imageTapped(row)
      print("image tapped func")
  }
  </code></pre>
  
  <p>Declared delegate in the Main VC</p>
  
  <pre><code>weak var delegate:postCell?
  </code></pre>
  
  <p>Assigned Delgate</p>
  
  <pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      //let post = posts[indexPath.row]
  
      if let cell = tableView.dequeueReusableCellWithIdentifier("PostCell") as? PostCell {
  
          var img: UIImage?
          var vImg: UIImage?
          postCell?.delegate = self
  </code></pre>
  
  <p>Added extension function</p>
  
  <pre><code>extension FeedVC: ImageSegueProtocol {
  
  func imageTapped(row: Int) {
      if inSearchMode == true {
          let object = filteredVenues[row]
          performSegueWithIdentifier("imageTapped", sender: object)
          print("ext func")
      } else {
          let object = posts[row]
          performSegueWithIdentifier("imageTapped", sender: object)
          print("ext func")
      }
  
  
  
  }
  </code></pre>