I'm Calling MainMenu View as:
MainMenu *obj=[[MenuViewController alloc] init];
[self presentModalViewController:obj animated:NO];
But it shows following error..
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MenuViewController" nib but the view outlet was not set.'
* Call stack at first throw:
Please Fix it.. thank you..
You need to open your nib in interface builder and connect your view with the view in File's Owner
i think your problem clearly in the error try to catch that error
loadViewFromNibNamed:bundle:] loaded the "MenuViewController" nib.....>>> but the view outlet was not set
Open your nib file and set your view outlet.
Related
Hey I'm trying to open a view controller that is designed using a xib interface file. I am using the following lines of code to generate the controller from within a view controller created as a storyboard component.
YourViewController *viewController [[YourViewControlleralloc] initWithNibName:#"ViewControllerName" bundle:nil];
[self presentViewController:viewController animated:YES completion:nil];
I have never set up a view controller with a .xib before nor have I ever linked to one via storyboard so anything could be wrong. Here is the error I am getting when I try to present the view.
2013-05-17 13:06:45.120 Coffee[8991:907] * Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason:
'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the
"PeekPagedScrollViewController" nib but the view outlet was not set.'
Set the File's Owner in the .xib to the class of your view controller (perhaps it is called PeekPagedScrollViewController).
Then connect its view outlet to the main view in the .xib file.
It was connected properly I had just forgotten to declare an initWithNibName method and therefore it crashed when I called it from storyboard. Silly mistake but thanks for all the great feedback #matt
Set the Storyboard view controller custom class to your class name (the one your xib is also referencing), then in that same class, simply override initWithCoder with:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [[super initWithCoder:aDecoder] initWithNibName:#"YourCustomViewControllerXibsName" bundle:nil];
if( self ) {
}
return self;
}
This will enable you to design layout and segue transitions in Storyboard, but design your layout in a standalone nib file.
Storyboard will handle instantiation, but when initWithCoder: is called, initWithNibName: will be the method that instantiates self via the xib.
I have an XIB that I present as a modal view. I have a button that calls the following -
(IBAction)dismissVC:(id)sender {
[self.parentViewController dismissModalViewControllerAnimated: YES];
}
When I press it the app crashes with this notice -
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController dismissVC:]: unrecognized selector sent to instance 0x8379350'
The thing I noticed is that I have a ViewController.xib file and I have this MapView.xib that is a modal VC I want to dismiss. It's presented from a ViewController.xib
What could be the possible issue? I've hooked up all the actions and the File Onwer thing as well.
Thanks in advance!
Try this:
unrecognized selector sent to instance
that might be your solution.
Please help me, I never made universal UIViewControllers with xib for iPhone/iPad. How I can create class with .m and .h files and _iphone.xib and _ipad.xib?
I was try to create xib manually and create outlets for view, but after pushing this controller I had uncaught error:
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "FullNewsViewController" nib but the view outlet was not set.
Thanks!
The problem, what I can see from the error you posted, is that you have not set the owner properties of the NIB correctly.
Your nib files does not seem to have the correct file's owner and thus can't set the view on the view controller.
Open the nib, and go to File's Owner in the left since of the screen. Set the Custom Class property to the class of your viewController.
The right click on the File's Owner again and drag the view property to your view.
You should follow Apple iOS App Programming Guide
Creating a Universal App
Here you will get some tips, how to create Universal Application.
Hope this will help you out.
REview this link may be helped you...
http://elusiveapps.com/blog/2011/10/converting-iphone-apps-to-univeral-ipad/
if the view controller can easily be used for both ....
MyViewController.h
MyViewController.m
MyViewController~ipad.xib
MyViewController~iphone.xib
Set the File's Owner in both the xib files to your UIViewController subclass and connect up the view + anything else you want connected.
When I init my view controller this is all that's required
MyViewController *viewController = [[MyViewController alloc] init];
// OR
MyViewController *viewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
The Apple docs for UIViewController state that if you provide a xib with the same name as the view controller it will be loaded. The ~ipad and ~iphone ensure that the correct xib is loaded.
I am trying to push a view from a button's IBAction and I am getting the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WebView initWithCoder:]: unrecognized selector sent to instance 0x68902b0'
Code:
-(IBAction)showWebsite:(id)sender {
NSLog(#"Web View!!!");
UIStoryboard* sb = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:#"web"];
[self.navigationController pushViewController:vc animated:YES];
}
Any idea what could have gone wrong?
_(IBAction) is connected to TouchUpInside
Make sure the .h of the second view is imported into the .m of the first view.
If you are using storyboard and just want to switch from one view to another view via a button you can place a button on the first view drop a second uiview controller onto storyboard then right click on the button and drag the connection to the second view.
To go back to the first view, repeat the process only this time connect the button on the second page to the first view.
I m calling rootviewcontroller from another view using below code
rootviewpage = [[RootViewController alloc]initWithNibName:#"RootViewController" bundle:nil];
[self.view addSubview:rootviewpage.view];
but the application terminate..pls check below error message .Tanks
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'RootViewController''
* First throw call stack:
you don't have a nib (a .xib file that is used for interfaces) that has the name RootViewController in your project..