didSelectRowAtIndexpath not responding to clicks

didselectrowatindexpath not called swift
didselectrowatindexpath not called custom cell
uitableview didselectrowatindexpath: not called sometimes
tableview didselectrowatindexpath not called first time
didselectrowat not called
tableview didselectrowatindexpath swift 3 not called
didselectrow is not getting called swift
didselectrowat is not being called

I'm making a revision app for high school students. In this view, the user should be able to select the units that they want to study for a certain subject, and the index path of the selected units will be stored in an int array and passed on to the next view for displaying images. Unfortunately, the didSelectRowAt method is not responding for some reason.

The delegate and data source are set correctly, I know that it is not getting called as I wrote a print statement in the function, and nothing was printed in the console when I click on any one the table cells.

var units = [String]()
var selectedRows = [Int]()

override func viewDidLoad() {
    super.viewDidLoad()
    tableView.delegate = self
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return units.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "unitCell", for: indexPath) as! UnitCell
    cell.textLabel?.text = units[indexPath.row]
    return cell
}

func tableView(tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    selectedRows.append(indexPath.row)
    print(selectedRows)
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let destination = segue.destination as! ImageView
    destination.folderNames = selectedRows
}

I expect an int array of row indexes of selected cells. But right now it is just empty.

If the code your showing in your question is accurate, the signature of the didSelectRowAt method is incorrect. It should be:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

Note the leading "_" for the first parameter. If your class is a UITableViewController, you'll also need to add an override keyword.

If your code is already using this signature, please update your question to reflect that.

Also, this leading code cannot be correct. Please update it to what you're actually using,

var units = String var selectedRows = Int

UItableview didSelectRowAtIndexPath not being called, UItableview didSelectRowAtIndexPath not being called. I am working on show weather project. I am listing the cities from database. When I click on a city,� If you added a gestureRecognizer on top of the UITableView, didSelectRowAtIndexPath will not get called. So you need to use gestureRecognizer delegate method to avoid touch in particular view.

You should use delegate method

optional func tableView(_ tableView: UITableView, 
         didSelectRowAt indexPath: IndexPath)

Instead of your existing one

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: IndexPath)

Try and share your results.

didSelectRowAtIndexPath not being called, Perhaps you have created a button or another user element in your table view cell. It is possible that it is “stealing” the clicks of your table view cell. Try to turn off user interaction on that element and see if your didSelectRowAtIndexPath function gets called. If you get the error message offering to close the program, choosing to close it that way is an easy path. You can also right-click the unresponsive program on the taskbar and choose Close, and this will usually cause that error message box to appear with the offer to close it.

UITableView didSelectRowAtIndexPath: not being called on first tap , UITableView didSelectRowAtIndexPath: not being called on first tap After that the clicks are smooth and didSelectRowAt fires immediately. If after trying the 4 fixes above, you still receive “Windows 10 file explorer not responding” error, use the steps below to repair Windows 10. Right-click Start menu and select Settings. Then, on the Windows Settings, click Update & Security. On the left pane of Windows Update, click Recovery.

-didSelectRowAtIndexPath: not being called in UITableView, When I click the UITableViewCell , It have selection effect (grey background in clicked cell),But didSelectRowAtIndexPath is not calling ,what happen? EDIT this � In my UITableViewController, I implemented -tableView:didSelectRowAtIndexPath:, but when I select a row at runtime, the method isn't being called. The table view is being populated though, so I know that other tableView methods in my controller are being called.

UITableView didSelectRowAtIndexPath not called � Issue #665 , And we can't handle click event on table view cell. P.S.. (void)tableView:( UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)� Next, you can click on Delete Browsing History to remove the useless data. For Google Chrome: You can click on Customize and Control menu and then select History. Finally you just need to hit Clear Browsing Data to wipe the cookies. For Firefox: Click on the menu, namely the three horizontal bar icon at the top right corner.

will/DidSelectRowAtIndexPath not called on tap � Issue #222 , I'm currently trying to use MGSwipeTableCell to enable our tables to have slide in buttons (that will expand to trigger an action). Now I run into� I have been looking until 6 o'clock this morning, but I can't figure out why the didSelectRowAtIndexPath method is not being called. I am getting quite desparate on this one. The tableview is shown properly, but I cannot succeed to enable the selection of a cell. In the header file , I

Comments
  • Can you check if other delegate methods are getting called or not?
  • Yes they are, the cells are set up correctly, and an empty array is passed onto the next view through prepareforsegue @KeyurTailor
  • @TimmyMi how you are doing segue, can you show us the code.
  • @MuhammadWaqasBhati sorry, I'm new to stack overflow, how do I share code in the comment area?
  • @TimmyMi edit your answer would be good.
  • Still nothing printed, I think the problem is that the method is not called when I click on my cell.
  • @TimmyMi Ok sure, if you face any issue, do let me know
  • Unfortunately, still nothing printed or passed onto the next view.
  • Hmm... can you edit your question and show me the code of your controller where you added my instructions.
  • Ok, I just edited the code in my question, please check, thank you orz
  • @TimmyMi where are you initializing your selectedRows like var selectedRows = [Int]() ? .... I could not see it in your code