So I have five different UIViewController that I would like to create. Each of them has a common thing (an image view on top, a label on top). So I was thinking of creating a parent UIViewController and then have 5 subclass from the parent UIViewController. In this parent view controller it will have the UIImageView, the label, and everything common/shared with the other five. The question is, each of this UIViewController subclass will have it’s own nib, however I want it to also have the parent’s UIImageView in place. How do I then deal with this?
I guess I am confused if each of the subclass UIViewController has it’s own nib, how can I see the parent view controller’s xib in this subclass? I know my wording is extremely confusing, I can’t seem to find a better way to explain this than this.
Don’t create a xib for the parent view controller. Instead, subclassing the parent view controller, then creating a xib for the subclass will expose the IBOutlets from any of the parent classes/view controllers.
Just think of this example, as we’ve all subclassed UIViewController at some point and created a xib for it, we must connect the main view in the xib to the “view” IBOutlet. We’ll that IBOutlet is defined in the UIViewController parent class.