Nicopuri
Nicopuri

Reputation: 981

Loading nib view into another nib view

I have two UIViews, let me called them as A and B. A is the container of B and each one is created using Interface Builder.

I need to add my B view into A using interface builder, like this image:

A UIView created using interface builder

B UIView created using interface builder

The problem is that the view is loaded but it's empty, when I debugged it I saw that every component is created.

The B UIView class definition is:

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];
}

I need to add a UIView into another UIView which every UIView is created with IB.

Upvotes: 2

Views: 350

Answers (1)

IPaPa
IPaPa

Reputation: 468

I think the problem is UIView in b.xib is 320x480 but View B in a.xib is not so it's not empty,it just out of range

Upvotes: 1

Related Questions