My goal is to perform segue when i tap on imageview of that cell. but the error does not appear when i use addTarget
on a button.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
cell.imageView.userInteractionEnabled = true
let tapImageView = UITapGestureRecognizer(target: self, action: #selector(HomeFeedViewController.tapImageView(_:)))
cell.imageView.addGestureRecognizer(tapImageView)
return cell as CastleCell
}
func tapImageView(sender: AnyObject) {
let center = sender.center
let point = sender.superview!!.convertPoint(center, toView:self.tableView) //line of error
let indexPath = self.tableView.indexPathForRowAtPoint(point)
let cell = self.tableView.cellForRowAtIndexPath(indexPath!) as! CastleCell
performSegueWithIdentifier("SegueName", sender: self)
}
The line of error is let point =
...
The error i get is:
fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)
but the error does not appear when i use addTarget
on a button. what could be wrong? thanks.