How to detect tableView cell touched or clicked in swift

后端 未结 9 877
灰色年华
灰色年华 2020-12-07 21:46

I\'m trying to get index of selected item in TableView and start some activity after that. Unfortunately most of solutions that I found are in obje

9条回答
  •  轮回少年
    2020-12-07 22:16

    This worked good for me:

        override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
            print("section: \(indexPath.section)")
            print("row: \(indexPath.row)")
        }

    The output should be:

    section: 0
    row: 0
    

提交回复
热议问题