Reputation: 68750
Newbie Q.
In my MainViewController, which is the first visible view.
I have a Circle class (no XIB) which subclasses UIView and overrides the draw method to draw a circle. Hello-World simple.
In the MainViewController how do I add the custom class I wrote so that it appears programatically?
Do I need to do anything besides overriding the draw method in Circle?
ian
Upvotes: 0
Views: 672
Reputation: 5133
If you are not loading MainViewController
's view
property from the NIB file (it's not connected to anything in interface builder), then I believe that you want to override the loadView method in MainViewController with something like:
- (void)loadView {
view = [[CircleView alloc] init];
}
This will get called automatically at the right time so when MainViewController is created, the view can be added to the window as a subview by whatever instantiates MainViewController.
Upvotes: 1