I have a group of collaborating controls in a cell prototype. I found that I wanted to reuse this same collaborating group outside of the table, in another view controller.
So I made a new UIViewController in my storyboard, moved all of the controls there and moved the interaction behavior from my UITableViewCell subclass to the new one. Now I just need to put a container view in the prototype cell in storyboard and hookup the embed segue. Easy enough.
What I don't know how to do though, is where the new sub view controller (my new subclass) will be instantiated, and how I can refer to it from cell subclass code? I need to pass some information from the cell's properties down to the embedded view controller. I can create an outlet for the container view in my cell, but that's for the view, not the embedded view controller.
When you embed a view controller inside another view controller, the container viewController's prepareForSegue: method is called - here you can keep a reference to the segue.destinationViewController.
And therein lies the problem - prepareForSegue: isn't a UITableViewCell method, so there's would be no way to capture the child view controller.
Of course, as you've discovered - you get a compile error in any case!
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