I am just starting in my iOS development using xCode 4.2 and discovered storyboards. They seem great for rapid prototyping.
What I’m wondering is how can I create my own custom control that I can use in multiple views.
For example, let’s say I want a custom title bar that is common on every view. I think I should be able to define that control with it’s own controller and instantiate that from multiple views. I just don’t know how and the tutorials and questions I’ve read so far don’t address this.
Any tips?
I’ve found one way to do this is to do the following steps:
(MyControl.xib)(MyViewController.h & MyViewController.m)File's Ownerof theMyControl.xibto the Custom ClassMyViewControllerParent.xib)IBOutletfor theUISCrollViewthat I will put the control into in theParentController.MyViewControllerin theParentController.ParentController, add the view of theMyViewControlleras a subview of theUIScrollView.In code, this means
This seems to work and allows me to separate the implementation of the Control and the Parent, but I can’t help but think there is a better way.