2
我有两个UIViews
,让我称他们为A
和B
。 A
是B
容器而且每一个是使用界面生成器创建的。加载笔尖查看到另一个笔尖视图
我需要使用Interface Builder我B
视图添加到A
,这样的形象:
的问题是,在视图加载,但它是空的,当我调试我看到每个组件都被创建。
的B
UIView
类的定义是:
BH(ISMSliderCustomizable.h)
@interface ISMSliderCustomizable : UIView {
IBOutlet UIView *view;
IBOutlet UISlider *slider;
IBOutlet UILabel *minLabel;
IBOutlet UILabel *maxLabel;
IBOutlet UIImageView *tooltip;
IBOutlet UILabel *sliderValue;
}
@property (nonatomic, retain) IBOutlet UIView *view;
@property (nonatomic) float min;
@property (nonatomic) float max;
@property (nonatomic) float initialValue;
@end
BM(ISMSliderCustomizable.m)
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
[[NSBundle mainBundle] loadNibNamed:@"ISMSliderCustomizable" owner:self options:nil];
[self addSubview:self.view];
}
return self;
}
- (void)awakeFromNib {
[super awakeFromNib];
[[NSBundle mainBundle] loadNibNamed:@"ISMSliderCustomizable" owner:self options:nil];
[self addSubview:self.view];
}
我需要一个UIView
添加到另一个UIView
其中每个UIView
都是用IB创建的。
我决定创建通过代码的子视图,我不想再用IB来浪费我的时间。谢谢。 – Nicopuri 2011-12-29 13:11:14