I originally asked this question. I had assumed that the reason for the slow load time of my custom view was because of layering multiple views on top of each other or perha
Tried something similar where a label and a text field were added as a subviews to a uiview subclass. The way I did was the following:
@interface CustomTextField : UIView
@property (weak, nonatomic) IBOutlet UITextField *valueField;
@end
So, we had a xib file on which we actually add the label and the text field. On the xib file, the file owner is "CustomTextField" and outlets are linked with the header file from there.
The constructor method looks like this:
- (id)initWithValue:(NSString *)value
{
self = [super initWithFrame:CGRectZero];
if (self) {
NSArray *nibs = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
UIView *view = nibs[0];
self.valueField.frame = view.bounds;
[self setFrame:view.bounds];
[self addSubview:view];
[self.valueField setText:value];
}
return self;
}
Works fine for me.