Reputation: 917
I developed an app in iphone now i need to also create this same app on ipad, I have the following files
LoginViewController.h
LoginViewController.m
LoginViewController.xib
now i added new file for ipad:
LoginViewController~ipad.xib
now i am getting an error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "LoginViewController" nib but the view outlet was not set.'
Upvotes: 2
Views: 534
Reputation: 49730
There are some step to go:-
create New Xib for Ipad like you say LoginViewController~ipad.xib
and open it.
click on file Owner--> and like bellow:-
now your ipad xib is also with your Loginviewcontroller customeClass
#import "Homeviewcontroller.h"
#import "LoginViewController.h"
#define isIpad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
//define here above implementation method
@implementation Homeviewcontroller
now if you want newNib load after crating as par above image you can load like bellow:-
if(isIpad)
{
LoginViewController *ObjLoginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController~ipad" bundle:nil];
}
else
{
LoginViewController *ObjLoginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
}
EDIT
Connect your FileOwner to main view like:-
Upvotes: 3