Upvote:10

var singleTap = UITapGestureRecognizer(target: self, action: 
#selector(self.tappedOnView))
singleTap.numberOfTapsRequired = 1
singleTap.numberOfTouchesRequired = 1
viewnanme.addGestureRecognizer(singleTap)

func tapped(onView gesture: UITapGestureRecognizer) 
{
    let location: CGPoint = gesture.location(in: tableView)
    let ipath: IndexPath? = tableView.indexPathForRow(at: location)
    let cellindex: UITableViewCell? = tableView.cellForRow(at: ipath ?? 
 IndexPath(row: 0, section: 0))
}

More Answer related to the Same Query

Upvote:2

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

Credit Goes to: stackoverflow.com

Related question with same questions but different answers