I'm a new developer and have a paperclip image in the custom cell of my table view. When I click the paperclip, it triggers a segue to open another viewController that is supposed to provide data relative to the row where the paperclip image is located.
I have a protocol set up to manage the navigation and the segues which is all working. The problem I have is that when I select the image, it does not go into the DidSelectRowAt method and consequently I'm not able to capture the relevant indexPath of the row that is selected.
Can someone point me in the direction of how to do that?
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "HealthLogCell", for: indexPath) as! LogTableViewCell
self.healthLog = healthLogs[indexPath.row]
cell.delegate = self
}
Protocol OpenLogDocumentsProtocol {
func openLogDocuments()
}
class LogTableViewCell: UITableViewCell {
var delegate: OpenLogDocumentsProtocol?
@IBOutlet weak var labelComment: UILabel!
@IBOutlet weak var labelDate: UILabel!
//THIS IS THE IMAGE THAT INTERACTS.
@IBOutlet weak var imagePaperclip: UIImageView!
var healthLog: HealthLog1?
override func awakeFromNib() {
super.awakeFromNib()
imagePaperclip.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(imageSelected)))
imagePaperclip.isUserInteractionEnabled = true
}
@objc func imageSelected() {
//print (superclass?.healthLog)
delegate?.openLogDocuments()
}
}