I would like to implement feature that if profileImage tapped in tableviewCell, segue to detailView. I add tapGesture but I still can\'t figure out how to get indexPath to p
Solution 1 : use touchBegun method, make sure imageView UserInteraction is enable
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
let touch = touches.first
if let cell = touch?.view?.superview?.superview as? YourCellClass {
let indexPath = yourTablView.indexPath(for: cell)
//Do whatever you want
}
}
Solution 2: you can use button.
@IBAction func onBtnClick(_ sender : UIButton) {
if let cell = sender.superview?.superview as? UITableViewCell {
let indexPath = tbl_songsInfo.indexPath(for: cell)
//Do whatever you want
}
}
Solution 3 : Same as above but use sender.tag
@IBAction func onBtnClick(_ sender : UIButton) {
let data = yourDataArray[sender.tag]
//Do whatever you want
}