I have a LegendViewController that shows a legend. Originally, I just plopped an UIImageView in there. However now, we need a few legends and I want to reuse the LegendViewController. So I created a new initializer:
- (id)initWithView:(UIView *)view withNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
[self initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[self.view addSubview:view];
}
return self;
}
So now this works assuming I pass in a UIView object. For one of my legends, I was wondering if I could load a .xib into my view controller without an image or a UIView object. I have a very simple legend where I just want some color coded squares (UIViews with colors), and some text (UILabels). I can create this in a standalone .xib file, but I wasn’t sure how I could load it into my LegendViewController. I’ve got so far as:
UINib *nib = [UINib nibWithNibName:@"HealthLegend" bundle:nil];
where HealthLegend is my standalone .xib file with my data. Or can this not be done and I need to either create an image in some drawing program, or draw the code manually in drawRect? Thanks.
From the reference guide
So I guess you want something like: