skip to Main Content

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.

enter image description here

enter image description here

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


  1. Chosen as BEST ANSWER

    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:

    enter image description here


  2. Have you tried implementing the UITableViewDelegate function?

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search