将笔尖视图加载到另一个笔尖视图中

时间:2011-12-27 13:44:53

标签: iphone ios interface-builder

我有两个UIViews,我将其称为ABAB的容器,每个容器都是使用Interface Builder创建的。

我需要使用界面构建器将B视图添加到A,如下图所示:

A UIView created using interface builder

B UIView created using interface builder

问题是视图已加载但它是空的,当我调试它时,我看到每个组件都已创建。

B UIView类定义是:

B.h(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

B.m(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创建的。

1 个答案:

答案 0 :(得分:1)

我认为问题是b.xib中的UIView是320x480 但是a.xib中的View B不是 所以它不是空的,它只是超出范围