If you created a separate class for tableView which is good practice, you can do it like this:
First create addTarget where the cell (cellForRowAt) is created:
cell.dropdownBtn.addTarget(self, action: #selector(self.openListPickerVC(_:)), for: .touchUpInside)
After that, submit the view controller in openListPickerVC ():
@objc func openListPickerVC(_ sender: UIButton) { let index = sender.tag let vc: PickerViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "PickerViewController") as! PickerViewController self.present(vc, animated: true, completion: nil) }
source share