Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift didSelectAtIndexPath doesn't get triggered

First of all I would like to describe what actually I am trying to do. I have two tableViewControllers - first one contains a list of bill's numbers and second one should displays the detail information about the bill depending on which cell of bill's number were selected.

In my first tableViewController I am using this to get bill's number from the cell and pass it to detailTableViewController:

 override func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
    let indexPath = tableView.indexPathForSelectedRow
    let currentCell = tableView.cellForRow(at: indexPath!) as! CustomBillTableViewCell

    valueToPass = currentCell.billNumberLabel.text
    print(valueToPass)
    performSegue(withIdentifier: "billsDetailSegue", sender: self)

}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "billsDetailSegue"){
        let detailController = segue.destination as! BillsDetailTableViewController
        detailController.receivedValue = valueToPass
    }
}

The problem is that didSelectRowAt function doesn't get triggered at all, after cell selection in the first tableView only prepare function triggers and It passes an empty value to the next view.

like image 685
Arina Fjodorova Avatar asked Apr 25 '26 14:04

Arina Fjodorova


1 Answers

you override didDeselect instead of didSelectRowAt.
And you probably set a segue for tapping on cell.
Disconnect it and connect segue from your whole viewController.

like image 195
Arash Etemad Avatar answered Apr 27 '26 04:04

Arash Etemad