I want to initialize a view with an xib. That is a UIView. So I have a xib and a UIView subclass with the init code pasted below (initWitFrame nibName). I feed the xib name to the init code from a view controller when creating the view.
SubclassUIView *view = [[SubclassUIView alloc]initWithFrame:self.view.bounds nibName:@"xibName"];
Am I on the right track? So far the contents of the xib does not load with the view.
By the way the main view in the xib is set to be the class type of my UIView subclass.
- (id)initWithFrame:(CGRect)frame nibName:(NSString*)nibName
{
self = [super initWithFrame:frame];
if (self)
{
[[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
[self addSubview:self.view];
}
return self;
}