I am, in all basics, wanting to have a view for iPhones, and one for iPads. However, I want to use the same view controllers for both of them, since they are the same thing, just optimized for each device.
I know it's possible to do this, because it is a universal app and the default views for a universal project include one main view for iPhones, and one main view for iPads. However, they're implemented automatically and so I don't know how to replicate this.
So, the jist of this question is: How do you have two xibs connected to one viewcontroller?
Thanks,
- Jake
First when you are loading the view you might have to check what device is it. If iPhone
xib1
otherwisexib2
. Regaring how to load the xib itself. its wasy. When you want to change views in aUIViewController
just just use this code:Dante has answered the problem I had with this. "Above that...one more important step is to go in each xib file..click on File Owner (Left column).. and in the i*dentity inspector* (icons on the top right side) .. make sure it is of class YOurViewController"
But I'll add that set all your buttons up in one Nib. Then place them but don't connect them in the second the way you would with the assistant view. Instead right click on File Owner in the left column and you'll see a whole table of your buttons and outlets ready to be connected to the objects in the new Nib.
Hope this helps.
From code :
From IB
Create 2 different version of "xib" file and specify the "file name" (1st group in properties window in xcode 4.3+), ie., for iphone add the iphone file name and for ipad add the ipad filename.
in code.. wherever you lot the new view ..do like this
You will have to replace the nib name and class name with yours..
Above that...one more important step is to go in each xib file..click on File Owner.. and in the i*dentity inspector* (icons on the top right side) .. make sure it is of class YOurViewController