ios - iPhone app converted to iPad app shows iPhone xib not iPad xib -


i in process of converting iphone app universal app.

  • i've changed xcode settings , added new mainwindow-ipad.xib
  • i've hooked interface builder references (e.g. mainwindow-ipad appropriate ipad class viewcontroller, window etc)
  • i've added new ipad class opening view controller , declared in appdelegate.h file, , synthesized them in appdelegate.m file:

    uiwindow *window; uiwindow *windowipad; appviewcontroller *viewcontroller; appviewcontrolleripad *viewcontrolleripad;

  • in app delegate check device running , load appropriate class:

    if (ui_user_interface_idiom() == uiuserinterfaceidiompad) {       // override point customization after application launch. navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontrolleripad]; // add view controller's view window , display. [windowipad addsubview:navcontroller.view]; [windowipad makekeyandvisible];  [navcontroller setnavigationbarhidden:yes animated:no];   } else { //i iphone!   // override point customization after application launch. navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontroller]; // add view controller's view window , display. [window addsubview:navcontroller.view]; [window makekeyandvisible];  [navcontroller setnavigationbarhidden:yes animated:no]; } 

and seems work fine - except still loads iphone nib/xib file appviewcontroller.xib instead of appviewcontrolleripad.xib. you're welcome ask more information can't figure out how load appviewcontrolleripad.xib when running ipad rather iphone/original xib file.

i thought, perhaps naively, if xib file has same name class of view controller viewcontroller use xib.

how can fix correct xib loaded correct device?

you have spelling mistake - correct sufix ipad resources "~ipad" instead of "-ipad". "~ipad" resources loaded automatically depending device.

and don't need uiwindow ipad controllers. can use same window @ app starting point. practice have 1 view controller (inside can perform special things different devices) , 2 nibs (one "normal" , second 1 "~ipad" sufix). in rare cases if whole controller behavior different may want use 2 view controllers.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -