title: Load UIView from XIB
body: <p>I'm looking for some advice on how to load UIView from XIB file. I tried following 5th solution from this <a href="http://eppz.eu/blog/uiview-from-xib/" rel="nofollow">tutorial</a>.</p>
  
  <p>However, the button actions won’t work. I setup my project almost exactly as the tutorial, but the IBAction just won’t get called at all. I'm not sure if adaptive layout caused this weirdness or not.</p>
  
  <p>Would you be kind enough to take a quick look at what happened in my project? I created a small project just to get the button working and is <a href="https://dl.dropboxusercontent.com/u/66024121/View_XIB.zip" rel="nofollow">placed here.</a></p>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>@interface ProfileHeadingViewOwner : NSObject
  @property (nonatomic, weak) IBOutlet ProfileHeadingView *profileHeadingView;
  @end
  
  @implementation ProfileHeadingViewOwner
  @end
  
  static ProfileHeadingViewOwner* __owner = nil;
  
  @interface ProfileHeadingView ()
  @property (nonatomic, weak) IBOutlet UILabel *profileName;
  @property (nonatomic, weak) UIViewController &lt;ProfileHeadingViewDelegate&gt; *delegateViewController;
  @end
  
  @implementation ProfileHeadingView
  
  +(void)presentInViewController:(UIViewController&lt;ProfileHeadingViewDelegate&gt;*) viewController
  {
      // Instantiating encapsulated here.
      //ProfileHeadingViewOwner *owner = [ProfileHeadingViewOwner new];
      __owner = [ProfileHeadingViewOwner new];
      [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:__owner options:nil];
  
      // Pass in a reference of the viewController.
      __owner.profileHeadingView.delegateViewController = viewController;
  
  
      // Add (thus retain).
      [viewController.view addSubview:__owner.profileHeadingView];
  }
  
  +(void)setProfileName:(NSString*)name {
      __owner.profileHeadingView.profileName.text = name;
  }
  
  
  -(IBAction)editAvatarButtonPressed:(UIButton *)sender {
  
      ////// THIS METHOD WON'T GET CALLED. WHY? ///////
  
      [self.delegateViewController uploadProfileAvatar:self];
  }
  </code></pre>
  
  <p>The <code>editAvatarButtonPressed</code>: method won't get called when the button is clicked.</p>
  
  <p>Thanks in advance.
  Loc Pham</p>