Swift TableView segue to new ViewController with wrong index path (penultimate selection)

后端 未结 2 1600
南方客
南方客 2021-01-27 02:08

I have a weird problem. I have two TableViews one for showing Projects and one for showing all Team Members. With both TableViews I have the same bug.

When a user click

2条回答
  •  滥情空心
    2021-01-27 02:44

    You are using the wrong delegate method. Perform the segue on selecting rather than deselecting a cell

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let post = posts[indexPath.row]
        performSegue(withIdentifier: "toDetails", sender: post)
    }
    

提交回复
热议问题