2

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.'

Alladinian
  • 34,483
  • 6
  • 89
  • 91
Adnan Khan
  • 897
  • 5
  • 14
  • 23
  • check this:-http://stackoverflow.com/questions/16787664/load-another-view-to-exist-tab-on-uitabbarcontroller/16787787#16787787 – Nitin Gohel May 29 '13 at 07:41
  • 1
    `LoginViewController~ipad.xib`->`view` needs to be set to `File Owner's`->`view` property in the Interface builder. – Amar May 29 '13 at 07:43
  • this post: http://stackoverflow.com/questions/4763519/loaded-nib-but-the-view-outlet-was-not-set-new-to-interfacebuilder explains everything – lakshmen May 29 '13 at 09:24

1 Answers1

3

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:-

enter image description here

now your ipad xib is also with your Loginviewcontroller customeClass

  • now you just need to check it IsIphone or Ipad like:-

#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:-

enter image description here

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Nitin you provide me the code of condition, where it will define? in .m? – Adnan Khan May 29 '13 at 08:45
  • Nitin in which file i put your code, i am not using "Homeviewcontroller.h", basically i am new with xcode. – Adnan Khan May 29 '13 at 10:14
  • Where you put you loginviewcontroller ? – Nitin Gohel May 29 '13 at 10:17
  • i mean in .h or .m file or other place? – Adnan Khan May 29 '13 at 10:19
  • where you want to push your loginviewcontroller there you put code for example at button click event you want to loginviewcontroller then in .m file button click-event u should put code as i mention in answer – Nitin Gohel May 29 '13 at 10:21
  • Nithin one more thing, I think issue is resolved but there is another issue,Unknown class LogonViewContrller in Interface Builder file. Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "LoginViewController" nib but the view outlet was not set.' how i can set outlet. – Adnan Khan May 29 '13 at 10:55
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/30821/discussion-between-nitin-gohel-and-adnan-khan) – Nitin Gohel May 29 '13 at 11:09