'Long press to select an option from a dropdown menu

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
}


Solution 1:[1]

Have you tried implementing the UITableViewDelegate function?

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Biclops