0

Hello I am just a beginner.

I have created a new xib file. Now I am trying to call it like the code below but it does not work.

This is what I have done in file's owner:

enter image description here

UIViewController *controller;
controller = [[UIViewController alloc]initWithNibName:@"UserFeedback" bundle:nil];
[self.view addSubview:controller.view];

The error that I am getting is:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "UserFeedback" nib but the view outlet was not set.'
Sarp Kaya
  • 3,686
  • 21
  • 64
  • 103
  • Don't use use UIViewController just make a subclass of UIViewController and use that subclass. And also the xib must be mapped with that subclass. – Exploring Feb 13 '13 at 06:25
  • http://stackoverflow.com/questions/4763519/loaded-nib-but-the-view-outlet-was-not-set-new-to-interfacebuilder – Praveen-K Feb 13 '13 at 06:54
  • I have doubt it whether it is set to the appropriate class AFMoviePlayerController or not. – Praveen-K Feb 13 '13 at 06:55

4 Answers4

1

I hope, you have created "controller.h" and "controller.m" UIViewController.

Then give the class "controller" into "UserFeedback" .xib file.

And bind the view object with "UserFeedback" .xib file.

Try with this and let me know.

Almost you will get success.

Cheers!

Nishant B
  • 2,897
  • 1
  • 18
  • 25
0

Here is the technique you can use:

UIViewController *controller; controller = [[UIViewController alloc]initWithNibName:@"UserFeedback" bundle:nil]; [self.view addSubview:controller.view];

the above code is correct but first u have check controller view is binding or not ..i think error is say that your not binding controller view

areddy
  • 77
  • 2
  • 14
0

Following diagram will help you understand

enter image description here.

As I can see from your code Now

 ATMoviePlayerController *controller;
 controller = [[ATMoviePlayerController alloc]initWithNibName:@"UserFeedback" bundle:nil];
 [self.view addSubview:controller.view];
Shashank Kulshrestha
  • 1,556
  • 17
  • 31
0

Seems the outlet is set correctly in the storyboard but while accessing it in the code you might have to ammend some code.

AFMoviePlayerController *controller = [[AFMoviePlayerController alloc]initWithNibName:@"UserFeedback" bundle:nil];
[self.view addSubview:controller.view];
AppleDelegate
  • 4,269
  • 1
  • 20
  • 27