Reputation: 994
I have an existing iPad - Application, no I want to make an universal App. There are many Tutorials with making iPhone Apps universall, but i dont find how to make iPad apps Universal. Is there somebody having experienxce with this?
No Storyboards are used, yust normal xib.
I've readed this tutorial, and porting iPhone apps to universal seems to be better supported by xcode: http://www.raywenderlich.com/1111/how-to-port-an-iphone-application-to-the-ipad
Upvotes: 1
Views: 1502
Reputation: 1817
I would think that the basic idea would be the same, whether you were converting an iPhone app to a universal app, or an iPad app to a universal one(?)
Set the iOS application target to "Universal".
If a view controller, say, XYZViewController has an associated xib for its UI, then - when you create a xib for the iPhone interface - append ~iphone to the name of the iPhone interface and ~ipad to the iPad one, i.e. their file names are XYZViewController~iphone.xib and XYZViewController~ipad.xib. That way the right xib will be picked up if you pass nil or @"XYZViewController" as nib name to the designated initializer for the view controller. (It's worth noting that the same IBOutlet can be hooked up to the corresponding UI elements in both xibs simultaneously.)
In code, whenever you need to use a different display metaphor that depends on the device type (say you want to use , check for the device type through the test
if ([UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { ... } else { ... }
Another place where you might want to use this test is in VC's shouldautorotatetointerfaceorientation: method.
Upvotes: 2