Tom

Development Lead (iOS)

16th August 2011

Making iOS apps Universal

Guides | Tutorial By 3 years ago

Turning your old iPhone or iPad app into a Universal app that natively supports both devices is fairly easy, as long as you know where to look and what to change. To clear confusion here is a step by step guide detailing exactly how to make an iPhone app Universal, the steps are nearly identical for an iPad app.

You will probably want to make a copy of your project before commencing, just in case something goes wrong.

  • Select the project in your left project navigator. Under the summary tab select ‘Universal’

 

  • If you run the project now your interface will show full screen on the iPad, although the same interface is being used

 

  • You will see in your Summary tab a new section has been created for the iPad (one named “iPhone/iPod Deployment Info” and another named “iPad Deployment Info”). The main interface file used for this device type is listed. The iPad default iPad one is called “MainWindow-iPad”, so create an Empty user interface file of this name. When prompted for the target device family choose iPad. Call this file “MainWindow-iPad”.

 

  • Instead of recreating every interface, go into your MainWindow.xib and copy every object and paste them into the MainWindow-iPad.xib. Everything will be iPhone sized, but we will fix this. Right click the xib and choose to open it as source code. Use find and replace to replace all instances of “{320, 460}” with “{768, 1024}”.┬áTo get back to interface builder mode open the file as Xcode.IDEKit…

 

  • For the MainWindow-iPad.xib, select the “File’s owner” and in the identity inspector on the right make this of custom class “UIApplication”. Right click the File’s owner and link up the delegate with the app delegate.

 

  • ┬áThat’s all. Run your app and it will use a different IB file depending on which device it’s targeting. Of course you may need to reposition objects for the other device. For dealing with various devices in code there is only one conditional statement you need to use
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
	//	iPhone/iPod touch code here
}
else
{
	//	iPad code here
}

Recommended Posts

Opening the Settings app programmatically in iOS 8

Post by 3 years ago

When iOS 7 first launched developers found the hidden URL schemes used by Apple to open the Settings app from another app. Developers started using this hidden URL in their apps. Apple realized and took

Got an idea?

We help entrepreneurs, organizations and established brands from around
the country bring ideas to life. We would love to hear from you!