2

I don't know what happens, but I can't set the delegate of a tableview anymore either via interface builder or programmatically.

Can't set the delegate

In interface builder, the delegate link for the tableView is gone, and programmatically, even if I set tableview.delegate = self, the method (didSelectRowAtIndexPath) is not called.

This is the first time it happens to me. It occurs only in my current project. On a new project, there is not this problem. Does anyone know why this can happen?

Thank you

1

2 Answers 2

0

Try to connect an outlet for the tableview and then add try the following in your view controller class:

self.yourTableView.delegate = self
self.yourTableView.dataSource = self

Make sure you've added UITableViewDataSource and UITableViewDelegate with the View controller definition. Like this,

class YourViewController : UIViewController, UITableViewDataSource, UITableViewDelegate {

}
1
  • 1
    Reading the question, he knows how to connect a tableView and it seems like an xCode bug
    – darksider
    Mar 22, 2017 at 9:41
0

In storyboard, go to your View controller window make sure your Utilities window is open and looking at Connections Inspector (rightmost icon) Now click on the ViewController icon in the ViewController's window header and it'll show you all connections. Now click on your tableView to select it and cntl-drag from tableview to VC icon in header. Delegate should be unchecked so select it. I think you need both the Delegate and DataSource to be connected. a blob against each and normal service should be resumed.

1
  • One further thought, check your tableview method signatures. If cellForRowAtIndexPath is called but didSelectRowAtIndexPath not. Create a new didSelectRowAtIndexPath and make sure the one you were using matches. Make sure it is autocompleting when you add it.
    – Cliff
    Mar 27, 2017 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.