UIView or UIViewController for custom View
What is the best way to create a custom UIView
that I can consume in Interface Builder?
Create a custom
UIView
in Interface Builder and inherit fromUIView
in a code file, then somehow use it in anotherUIView
ala like a control. (How do I do this?)C开发者_开发问答reate a custom
UIView
in Interface Builder and have a customUIViewController
wire it up. In my mainViewController
, place the new view.
Basically, I am trying to create a reusable display view and would like a quick way to change it across all my instances with minimal effort. I already have laid out my XIB in Interface Builder.
The best is the 1st way. And don't forget to place IBOutlet keyword before class member, that you want to see in Interface Builder.
@interface MyViewController : UIViewController {
IBOutlet UILabel *m_MyLabel;
}
....
You'll want to do (1). Presumably you've got an existing IB file in which you'd like to place the custom UIView subclass? In that case, go to that file, drag out a UIView, and then in the "Application Identity" tab of the inspector (4th tab) set the Class to your custom class (as defined in code).
精彩评论