I have a project that was intended to be an iPhone app in first instance, but now I want it to also support iPad. I have changed project’s target from iPhone to Universal, but I dont know how to manage both nib versions I need now, already having nibs designed for iPhone. I tried by loading same viewControllers with different nibs according to the device, but Im not allowed to set more than one interface control to the same outlets. Any help? I have Xcode 4.4
Share
It’s pretty easy.
For your storyboard files, just include the
_iPadand_iPhonesuffixes.For example, if the original storyboard name is
MyStoryboard.storyboard, you’ll now haveMyStoryboard_iPad.storyboardandMyStoryboard_iPhone.storyboard. You can also set the storyboard file for each device under the summary view of the project.Then, for the.xib files, include the
~iPhoneand~iPadsuffixes.ViewController.xibbecomesViewController~iPad.xibandViewController~iPhone.xibTo start off, you can just create a duplicate if your existing .xib files and rename them to have the iPad and iPhone suffixes. Then alter the contents of each .xib as needed.
As for the .m code, you can check device type and branch your code. My approach is to define macros that identify device type, like this:
Then I just use these macros(which return bool values) to write code that’s specific to a device type(such as placement or dimensions of a particular view etc.).