2

I am trying to upgrade my existing iPhone app project to an Universal app, I have implemented following steps,

Step 1: Project Navigator - target - Summary - devices - Universal (From iPhone to Universal)

Step 2: Created TabBar with NavigationBar Flow in Storyboard,

When i run my project in iPhone it works properly but when i run in iPad it shows only TabBar with NavigationBar.

Now my problem is how to create new .xib files for iPad ? Xocde doesn't created automatically when i selected my device from iPhone to Universal.

or

How to map my iPhone .xib files with iPad.

Do i need to create new Outlet and action for all buttons which are there in my iPhone .xib?

Thanks in advance.

Krunal
  • 6,440
  • 21
  • 91
  • 155
  • Are you using storyboard or indivitual xib files or a mix of both? – Hermann Klecker Sep 05 '13 at 07:45
  • mix of both, storyboard and xib files for each view controller. – Krunal Sep 05 '13 at 07:46
  • you need to create new xib files for your each ipad screen and that thing you can do with dragging viewcontroller component from right side to storyboard and select the size of view controller from iphone screen to ipad screen – D-eptdeveloper Sep 05 '13 at 07:46
  • It is right that xcode does not create the xib files for ipad automatically. You will have to do that yourself and programmatically (or by configuration within the respective storyboard) decide on which to call. In some easy cases you could use the same view controller with the ipad and the iphone version of an xib file. If you really want to leverage from the ipad's capabilities then you may get some toally different navigation logic which may (or may not depending non how smart your architecture is) require iPad specific view controllers too. – Hermann Klecker Sep 05 '13 at 07:48
  • Allright, a mix of both. That is not a bad idea. Your app will fire the device type specific storyboard. Then you go from there. I assume that you push or present individual view controllers with stand-alone xib files programmatically. There you could programmatically decide whether you are on an ipad or not and call either one or the other. Frankly I am not sure if the ~ipad suffix in a file name works for xib files in the same way as it would for images or other resources. (I think I read about that but I never tried it myself with xib file names.) – Hermann Klecker Sep 05 '13 at 07:52
  • I have created new xib file for iPad, now how should i map this with my view controller ? – Krunal Sep 05 '13 at 07:54

1 Answers1

5

enter image description here Create a new xib for all your view controllers ,name the view controllers with "~ipad " as a suffix(ex. FirstViewController~ipad.xib)

enter image description here

xcode will automatically use the xib when the application run in ipad. Link your newly created xib with appropriate classes through identity inspector in xib.

Note : After creating a new xib, add all the controls as added in existing view controller and link newly added controls with file owner.

enter image description here

add all the controls and link with file owner.

Ganapathy
  • 4,594
  • 5
  • 23
  • 41
  • I tried your suggestion, when i try to run my code in iPad it takes the `.xib` of iPhone not `.xib` of iPad, Here are `.xib` names `BTSHomeViewController.xib` for iPhone and `BTSHomeViewController~iPad.xib` for iPad – Krunal Sep 05 '13 at 11:37
  • 1
    Xib name is a case sensitive. Just try like with this "BTSHomeViewController~ipad.xib" – Ganapathy Sep 05 '13 at 12:10