Search code examples
iosiphoneipadxcode5

How to create iPad xib file in iPhone specific project


I did a project few days back for iPhone but now i want to add iPad xib file into it. As features are enhancing. But the problem is that, at starting i selected an iPhone target for xib file not universal project.

So now i want to add xib for iPad's .

I created a new xib file for iPad but don't know how to load this on iPad instead of default xib file which is created for iPhone.

I have been checking a lot of other questions but didn't find any correct answer.Xcode 4 .xib Create iPad Version But its not working for me

I'm working on Xcode 5 and iOS 7.0.x


Solution

  • For automatic loading xib for iPad add ~ipad to the name of xib file.
    For example:
    If name of xib for iPhone version is CustomVC.xib
    then for iPad version use CustomVC~ipad.xib.
    When you create object of vc CustomVC *vc = [[CustomVC alloc] init]; iOS will automatically choose correct xib file depending on platform (iPhone or iPad) where application is run.