I have to do a long press to select an option from a dropdown menu. I want the selection to be immediate. How can I solve this problem.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = UITableViewCell()
cell = countryTableView.dequeueReusableCell(withIdentifier: "countryCell", for: indexPath)
cell.textLabel?.text = country[indexPath.row]
return cell
}
2
Answers
I found the solution in this link:
didSelectRowAtIndexPath not being called
Is There a UITapestureRecognizer Have you created a UITapGestureRecognizer on top of your table view?
It’s possible that the UITapGestureRecognizer is swallowing your click events before they reach your table view.
To resolve this, set the cancelsTouchesInView property of the UITapGestureRecognizer to false.
You can also set this in your storyboard by selecting the UITapGestureRecognizer, navigating to the property inspector and unchecking this box:
Have you tried implementing the UITableViewDelegate function?
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)