2

I read document about universal app's and i read how to convert iphone application to ipad, but can i convert my ipad application to iphone application?

Is there any tutorial for universal application?

PJR
  • 13,052
  • 13
  • 64
  • 104

2 Answers2

6

Yes you can.

in XCode, select your application, and pick "Universal" from the Device family and presto, your app is now universal.

Nils Munch
  • 8,805
  • 11
  • 51
  • 103
5

While Nils approach will get you started, you will also need to create new XIB's that are structured for the smaller interface. You will also need to determine in code what view you are loading for which device.

if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
    /*  do something for the iPad  */
else
    /*  do something for the iPhone  */

Here is one tutorial (of many on Google): http://blog.corywiles.com/creating-a-universal-ios-app-tutorial

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • Actually, XCode does this automatically. But your code can be used for other issues as well, so no downvote. – Nils Munch Jul 28 '11 at 06:53
  • Actually, Xcode does not automatically structure XIB's for both iPhone and iPad. Xcode 3.x and Interface Builder used to have an option to do this. – WrightsCS Jul 28 '11 at 06:54
  • Theoretically, if you use the `AutoResizingMasks` correctly, you can get away with some things, but for the most part, you are better off creating the device specific interfaces (if you use them). – WrightsCS Jul 28 '11 at 06:57
  • A bit confused. When I make a blank project in XCode, starting out on iphone, and then change the project to universal, this code is automatically integrated in my project, and the app selects the respective XIB for the different devices. But nothing wrong in manually scripting it. – Nils Munch Jul 28 '11 at 06:58
  • What do you mean by "the app selects the respective XIB for the different devices". Where do these "respective XIB's" come from? – WrightsCS Jul 28 '11 at 07:00
  • XCode offers me to create these when i switch from iphone to universal. "The Main Interface used for running on iPhone can be used as a starting point for your iPad development. Would you like to copy and convert 'MainWindow' to be used as a starting point for running on iPad?" I don't use any other xibs. – Nils Munch Jul 28 '11 at 07:03
  • @NilsMunch let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/1910/discussion-between-wrightscs-and-nils-munch) – WrightsCS Jul 28 '11 at 07:04
  • k. its offline for maintenance, but your syntax is correct. I can recommend adding NSClassFromString(@"UISplitViewController") != nil && to the if sentence (UIUserInterfaceIdiomPad constant is available only on iOS 3.2 and up) Have to head to work myself. – Nils Munch Jul 28 '11 at 07:09