我正在使用单独UIView
的类,该类awakeFromNib
从这是我的自定义类的视图层次结构,我必须在其中添加自定义视图contentView
。我不知道如何将我的 customViews 作为子视图添加到 contentView。
这是我所做的尝试,但我失败了。
#pragma mark - UINibLoading
-(void)awakeFromNib {
scrollView.translatesAutoresizingMaskIntoConstraints = NO;
[self loadViewIntoMemory];
[self formUpdateDetailsData];
}
#pragma mark - Private
- (void)loadViewIntoMemory {
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
[self addSubview:contentView];
}
- (void)formUpdateDetailsData {
for (int i = 1; i < 5; i++) {
inputTextView = [[UIView alloc] initWithFrame:CGRectMake(15, ((i*44)+(i*15)), inputTextView.frame.size.width, 44)];
[contentView addSubview:inputTextView];
}
for (int i = 5; i < 10; i++) {
inputPickerView = [[UIView alloc] initWithFrame:CGRectMake(15, ((i*44)+(i*15)), inputPickerView.frame.size.width, 44)];
[contentView addSubview:inputPickerView];
}
}