title: iOS: Custom view with xib
body: <p>I'm missing something important. Not exactly sure what it is.</p>
  
  <p>I have a custom view subclass. I created a xib file to design its layout. I connected four buttons as outlets to the class.</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface MCQView : UIView
  @property (strong, nonatomic) IBOutlet UIButton *btn1;
  @property (strong, nonatomic) IBOutlet UIButton *btn2;
  @property (strong, nonatomic) IBOutlet UIButton *btn3;
  @property (strong, nonatomic) IBOutlet UIButton *btn4;
  </code></pre>
  
  <p>I then have</p>
  
  <pre><code>#import "MCQView.h"
  
  @implementation MCQView
  @synthesize btn1,btn2,btn3,btn4;
  
  - (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self) {
          [self addSubview:[[[NSBundle mainBundle] loadNibNamed:@"MCQView" owner:self options:nil] objectAtIndex:0]];
              NSLog(@"%@", btn1);
  
      return self;
  }
  </code></pre>
  
  <p>I then add the view to another view controller via: <code>initWithFrame</code>.</p>
  
  <p>When I try to log btn1, to see if it exists, it prints null. I assume that its because I haven't initialized it, but I'm not exactly sure how to do that, considering that if I create it as a new button then all of the stuff in the xib will be useless?</p>