title: iOS - Interface Builder - bind multiple view inside the same xib
body: <p>I'm trying to organize a complex xib into multiple view.</p>
  
  <p>Suppose the following scenario:</p>
  
  <p><img src="https://i.stack.imgur.com/H4cn9.png" alt=""></p>
  
  <p>I have the main view (the green one) that contains two subviews (the red and the yellow ones).<br>
  Actually I can create three xib and add the subviews programmatically.<br>
  I found a solution a bit smarter: I define two IBOutlet in the main view (green) and connect them to the subviews.</p>
  
  <pre><code>@property (nonatomic, weak) IBOutlet RedView * redView;
  @property (nonatomic, weak) IBOutlet YellowView * yellowView;
  </code></pre>
  
  <p>In the main view implementation, programmatically, I add the subviews:</p>
  
  <pre><code>- (void)awakeFromNib
  {
      [super awakeFromNib];
      self.redView.frame = self.frame;
      self.redView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
      self.yellowView.frame = self.frame;
      self.yellowView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
  
      [self addSubview:self.redView];
      [self addSubview:self.yellowView];
  }
  </code></pre>
  
  <p>As you can see, I need to set the current frame size, the autoresizingMask and add the subViews to the parent.</p>
  
  <p>The question:</p>
  
  <p>is there a nice way to perform these operations directly from the xib?
  I want to load the xib ("loadNibNamed") and obtain the main view (green) already filled with the subviews.  </p>
  
  <p>I've tried some solutions but neither works...</p>
  
  <p><strong>edit:</strong><br>
  I don't want to add the red and yellow view as subviews directly in IB.<br>
  The two subviews are as big as the parent and this make complex to work with Interface Builder (hide the yellow view and work on the red, then hide the red and work on the yellow...).<br>
  I'd like to have separate views in the same xib but being able to "compose" them in parent-child tree...  </p>