Вы можете реализовать протокол UITableViewDelegate
для фактического обнаружения прослушиваемой ячейки:
extension MyOriginViewController {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// I'm assuming you have only 1 section
switch indexPath.row {
case 0:
// Instantiate the VC
let vc = storyboard?.instantiateViewController(withIdentifier: "MyViewControllerIdentifier")
// Present the view controller, I'm using a UINavigationController for that
navigationController?.push(vc, animated: true)
case 1:
// Another VC and push or present modally
let vc = ...
self.present(vc, animated: true, completion: nil)
default:
// Default case (unconsidered index)
print("Do something else")
}
}
}
Так что если у вас есть это:
Вы можно сделать:
let vc = storyboard?.instantiateViewController(withIdentifier: "MyNavController")
self.navigationController?.present(vc, animated: true, completion: nil)