title: Using xib object inside another xib
body: <p>I'm designing using IB a specific button (with some labels,and imageView and other stuff).</p>
  
  <p>I would like then to use that xib object (the button) in another xib, where I have 6 objects of that button.</p>
  
  <p>I know I can do that programmatically using the Class Identifier, but then I have to position my lables and image view, and set the default values and everything else in code.</p>
  
  <p>I'm wondering if it's possible to do the same thing using just the IB ? (of course I would still set the values in code, but I want to positions of the lables/imageView and all the rest to be set in the xib)</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit</strong></p>
  
  <p>So, I understand what I asked for at first is not possible.
  What I'm trying now is like that :</p>
  
  <p>I created a <code>ButtonTest.xib</code>.
  Inside the Xib I have a UIView and 3 subviews (2 lables and a button).
  In the inspector I set the UIView class to <code>ButtonTest</code>.
  Inside ButtonTest.m I have 3 outlets for each of the subviews, which I connect in IB.</p>
  
  <p>Next I have a <code>ButtonTestViewController.xib</code>.
  Inside it I put one view and set it's class in the inspector to be <code>ButtonTest</code>.
  I connect that view to a <code>myTextView</code> outlet inside <code>ButtonTestViewController.m</code> of class <code>ButtonTest</code> </p>
  
  <p>Now, this is the code inside ButtonTestViewController.m viewDidLoad:</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
  
      NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"ButtonTest" owner:nil options:nil];
      ButtonTest *mainView = (ButtonTest*)[subviewArray objectAtIndex:0];
  
      self.myTextView = mainView;
  }
  </code></pre>
  
  <p>What I hoped would happen, is that the view in ButtonTestViewController.xib would become the view I designed in  ButtonTest.xib.
  This just isn't happening. what happens is that the view inside ButtonTestViewController.xib stays the same.</p>
  
  <p>Worth mentioning, is that if I add:</p>
  
  <pre><code>[self.view addSubview:mainView];
  </code></pre>
  
  <p>It does add the new view, besides the existing one.</p>
  
  <p>Any idea how to do what I want ?</p>
  
  <p>Eventually I would like to have 6 views in <code>ButtonTestViewController.xib</code>, all would look like the ButtonTest.xib template, and the lables values will be set in code.</p>
  
  <p><strong>Edit2</strong></p>
  
  <p>Ok, guys I did everything you said and it worked like a charm.
  The only problem I have right now with this issue is when the view in <code>ButtonTestViewController.xib</code> is a little bigger then view in <code>ButtonTest.xib</code>.
  When that happens, The lable on the button look extremely blurry.
  When they are both the same size, it's all good.</p>
  
  <p>@ Ned - I used the exact code you posted in my InitWithCoder method, except I switched the frame sentence to this :</p>
  
  <pre><code>self.bounds = mainView.frame;
  </code></pre>
  
  <p>I tried playing with the content mode in IB trying to fix it, to no avail.</p>
  
  <p>When I do use it like you posted, meaning :</p>
  
  <pre><code>mainView.frame = self.bounds;
  </code></pre>
  
  <p>It's not working at all, and both views' sizes stay the same.
  Here I tried playing with the resizeMask but still didn't work.</p>
  
  <p>And idea how to fix these 2 issues ?
  Thanks guys!</p>
  
  <p><strong>Edit 3</strong></p>
  
  <p>I did manage to fix one of the issues, resizing the <code>ButtonTestViewController.xib</code> to the <code>ButtonTest.xib</code> view size.
  This is what I did (using code to solve the blurry issue, taken from <a href="http://www.markj.net/iphone-uiview-blurred-blurry-view/" rel="noreferrer">here</a>)</p>
  
  <pre><code>self.bounds = CGRectMake(0, 0, mainView.frame.size.width, mainView.frame.size.height);
          CGRect overlay2Frame = self.frame;
          overlay2Frame.origin.x = round(overlay2Frame.origin.x);
          overlay2Frame.origin.y = round(overlay2Frame.origin.y);
          self.frame = overlay2Frame;
  </code></pre>
  
  <p>The other issue I still can't solve. the view in ButtonTest.xib just won't get bigger to match the other view.</p>