I am building a simple app with a table view filled with custom view cells and using a storyboard. I want to add a actions on the cell each time the user tap it.
So far, I tried to create an IBOutle
to link my cell to my tableViewController
and add the action manually in the code but each time I try to do it I get an error message saying "Illegal Configuration - cannot have a prototype object as its destination".
The only quick fix I found is to add a UIButton
with a transparent background and no title which fills in the whole cell and attached the action to it.
Is there any more elegant way to do it?
Not only is there a more "elegant" solution, but there is also a correct way to do this.You should be using the didSelectRowAtIndexPath
method for your cells.
You should read what the Apple Docs have to say
And also, here is a tutorial on how to use row selection in your tableView.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With