Unable to load detached NIB in View

Posted by Sheehan Alam on Stack Overflow See other posts from Stack Overflow or by Sheehan Alam
Published on 2010-04-07T02:09:40Z Indexed on 2010/04/07 2:13 UTC
Read the original article Hit count: 379

I have two NIB's

ParentViewController.xib
ChildViewController.xib

ParentViewController.xib contains a UIView and a UIViewController. ChildViewController.xib contains a UIButton

I want ChildViewController.xib to load in the ParentViewController.xib's UIView

I have done the following:

  1. Created @property for UIView in ParentViewController
  2. Connected File's Owner to UIView in ParentViewController
  3. Set UIViewController in ParentViewController's NIB Name property to ChildViewController in Interface Builder
  4. Set ChildViewController view property to UIView in ParentViewController

I was hoping this would load ChildViewController into my UIView in ParentViewController but no luck.

I did get the following warning, which could be the culprit:

'View Controller (Child View)' has both its 'NIB Name' property set and its 'view' outlet connected. This configuration is not supported.

I also have added additional code in ParentViewController's viewDidLoad():

- (void)viewDidLoad {
    [super viewDidLoad];
    ChildViewController *childViewController = [[ChildViewController alloc]initWithNibName:@"ChildViewController" bundle:nil]; 
    childViewController.view = self.myView; 
}

Any thoughts on why ChildViewController does not load in the UIView of ParentViewController?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa-touch