In my App I have a ParentViewController that have several elements in it. One of the elements is a UITableView.
I designed the table’s cells using a Dynamic Prototype Cell that I had designed within the Storyboard.
Meaning, that I have in the Storyboard a UIViewController; inside it I have a UITableView; and inside the UITableView I have a Prototype Cell.
Now, I added a UIButton inside the the Prototype Cell, created another UIViewController (let’s call it ChildViewController) and connected the UIButton and the ChildViewController within the Storyboard with a Segue.
How should I write the code that activates the Segue when the user clicks the UIButton?
I managed to create the table itself and have data inside the Dynamic Cells (they have some UILabels aside to the UIButton), but I cannot figure out how to connect the UIButton to the code properly.
I don’t want to use the UITableView default “select” features, since I wish to have several buttons inside the Dynamic Cells – each one will derive a different segue to a different ChildViewController.
Here’s how I solved the same problem. Hope it will help.
To do this, you can pass the pointer to your UITableViewController to your custom cell’s initialization method, and store it there:
Save the pointer in custom UITableViewCell class:
Then, you can perform a segue when the button is tapped:
Any better ideas?