0

i created a tabBar app with ARC. So the default set up would automatically provide 2 viewControllers;

1) FirstViewController.h,FirstViewController.m;FirstViewController_iPhone.xib, FirstViewController_iPad.xib

2) SecondViewController.h, SecondViewController.m, SecondViewController_iPhone.xib, SecondViewController_iPad.xib

I wanted to create a new view controller 'ViewController3' but during the file creation process, i can only opt to create for iPad or just iPhone (checkbox 'Targeted for iPad'). I need both iPhone and iPad xibs just like the FirstViewController and SecondViewControllers created for me. So i decided to create the xib manually and continued with the file creation without xibs.

So naturally after that i went on to manually create 2 news xibs; ThirdViewController_iPhone.xib and ThirdViewController_iPad.xib

i added this line into the original AppDelegeate file:

UIViewController *viewController1, *viewController2, *viewController3;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil];
    viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil];
    viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPhone" bundle:nil]; 
} else {
    viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPad" bundle:nil];
    viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPad" bundle:nil];
    viewController3 = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController_iPad" bundle:nil];
}
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil];

I then run the project and got this: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ThirdViewController_iPhone" nib but the view outlet was not set.'

How do i set the outlet?

Joe Shamuraq
  • 1,245
  • 3
  • 18
  • 32
  • You need to hook the view up to file's owner in the xibs – Paul.s May 01 '12 at 21:07
  • I clicked on the file's owner of the manually created xibs. Then i used the class property (somewhere near the inspector panel) to enter the name of the viewcontroller as the class... Still no success... – Joe Shamuraq May 01 '12 at 22:31
  • `ctrl` + `drag` from the `File's Owner` to the `view`, then from the HUD select `view` - this is what I meant previously – Paul.s May 01 '12 at 22:42

1 Answers1

4

For your ThirdViewController_iPhone.xib, follow the instruction here. I think you need to do this step:

  • You should see "outlets" with "view" under it. Drag the circle next to it over to the "view" icon on the left bar
Community
  • 1
  • 1