I am getting an error while I tried to push ViewController in table's didSelectRow in iPad app.
Error which I get is:
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle /Users/abc/Library/Application Support/iPhone Simulator/4.2/Applications/CFC7803E-4E44-45BF-9F47-``E24DDB44F286/SampleIpad.app> (loaded)' with name 'DetailView''
Code in table's didSelectRow method :
DetailView *detailViewController = [[DetailView alloc] initWithNibName:#"DetailView" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
What can be done?
To do so, Right click the viewController .m file in Xcode
Click GetInfo
Go to Targets tab and check if the checkbox next to your target project is checked? If not, do check that checkbox.
Clean and Rebuild your code.
This would work for you.
This error is due to the missing nib file.Check whether your application folder on the disk contains the DetailView.xib file. If it is present you may try using [NSBundle mainBundle] instead of nil in the bundle parameter.
Try this
[NSBundle mainBundle];
Related
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 have a game with 4 game modes. the problem is that I want to create a main menu to choose a mode, because instead of that menu there is a TabBar. I'm trying to do that putting each mode in different .xib files, and create an other .xib file for the menu.
Menu.m:
-(IBAction)PlayMode1:(id)sender{
ViewController *Mode1 = [[ViewController alloc] init];
[self presentModalViewController:Mode1 animated:YES];
[Mode1 release];
}
with this I'm getting this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '- [UIViewController _loadViewFromNibNamed:bundle:] loaded the "ViewController" nib but the view outlet was not set.'
I checked that "view" is linked to "View" on IB so I don't know what to do...
I'm not an advanced developer, thanks for helping!
You should try to do the following:
-(IBAction)PlayMode1:(id)sender{
ViewController *Mode1 = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
[self presentModalViewController:Mode1 animated:YES];
[Mode1 release];
}
Seems like you forget to put initWithNibName inside the allocation of the view.
Also, make sure that your ViewController.xib is the correct name of the view controller and check if it has the correct outlets linked.
Check View Identity > Class Identity is set too. If not, type in the name of your controller, ViewController
EDIT
Remove everything in the xib, "Window" and "ViewController".
Drag an UIView on the left column and set its outlet.
Click on File's Owner and then, on the Inspector, Identity inspector section (third one from the left), type in the class of your view, `ViewController´.
I'm new to programming in objective C so I have a feeling this is just something really stupid I'm doing or failing to do...
I have an iPhone app and am trying to navigate from one view to another. I hooked up a segue and when I call it, like this:
[self performSegueWithIdentifier:#"ShowPolicyInformation" sender:sender];
it works just fine. But now I want to pass a value to my new view, and from what I can tell I can't do that with a segue. So I setup some properties on it and am trying to navigate to it more manually:
PolicyInfoViewController *pol =[[PolicyInfoViewController alloc] initWithNibName:#"PolicyViewController" bundle:nil];
pol.PropertyOne=txtOne.text;
pol.strPropertyTwo=txtTwo.text;
[[self navigationController] pushViewController:pol animated:YES];
When I replace the performSeque code with the code above, it builds fine, but I get this error when I run it:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'MainMobileViewController''
When I search for help with this issue, all of the suggests that are shown talk about making sure the .xib file is named correctly....and here is where I'm completely lost, because I don't have any .xib files that I can see. I'm working with a storyboard and just drag/dropping the views onto it and connecting it to classes I create. So...what newbie mistake am I making? What am I missing? I am working with xCode 4.4, so is this just different code than what I'm finding in these searches? Any help or advice would be greatly appreciated.
You can perform this by using Story Board only and not having to have a separate nib file for the PolicyInfoViewController... It would probably easier for you to do it this way.
so in keeping the first line of code:
[self performSegueWithIdentifier:#"ShowPolicyInformation" sender:sender];
You would need to override this method to manipulate properties of the PolicyInfoViewController
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:#"ShowPolicyInformation"])
{
PolicyInfoViewController *pol = segue.destinationViewController;
pol.PropertyOne=txtOne.text;
pol.strPropertyTwo=txtTwo.text;
}
}
So what is happening here? First bit of code you are telling the control to perform the particular segue from story board. Second bit you are telling control what to do when a particular segue is called.
I'm developing an iPhone app that is a "module" of another launcher (it doesn't launch from the iPhone home screen). To add this module to the launcher, I have to drop in the xcode file into the parent xcode project (creating a subproject). The subproject uses a NIB file as its view controller and the subproject loads the file using initWithNib:
root_view_controller = [[UINavigationController alloc] initWithRootViewController:[[LMU_IP_RootView alloc] initWithNibName:#"LMU_IP_RootView" bundle:nil]];
When I try to run the parent project, it crashes with:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle [...] (loaded)' with name 'LMU_IP_RootView''
I'm guessing its because it can't find the NIB file because the root bundle is now the parent project instead of the subproject. I could include the NIB in the parent project and that fixes the error, but doesn't solve my problem.
So my question: How do I use InterfaceBuilder files in a subproject? Do I have to specify a bundle? How do I specify a bundle that refers to this subproject?
Thanks!
When bundle is nil, the search is performed in the main bundle, not in your subproject bundle. I'm not entirely clear on your app architecture, but try specifying the bundle containing the class as the bundle to search:
NSBundle *classBundle = [NSBundle bundleForClass:[LMU_IP_RootView class]];
id vc = [[LMU_IP_RootView alloc] initWithNibName:nil bundle:classBundle]
root_view_controller = [[UINavigationController alloc]
initWithRootViewController:vc];
[vc release];
Note that a nil nib name defaults to "ClassName.nib", so LMU_IP_RootView.nib will be searched for in this case.
It's generally better to override -init in your view controller class so it performs the correct lookup. Then client code doesn't have to worry about what nibs the class needs.