1

My xcode version is 3.2.5.

My application was created on iPhone. I want that which I had written for iPhone should be run and work for iPad. How to work on this?

Help me friend, how to create this type of application?

Benjie
  • 7,701
  • 5
  • 29
  • 44
Rocky
  • 1,427
  • 1
  • 28
  • 65
  • possible duplicate of [Universal application](http://stackoverflow.com/questions/5321932/universal-application) – Brad Larson Nov 18 '11 at 16:34
  • See also [What are the Build Settings for a Universal iPhone and iPad Application](http://stackoverflow.com/questions/2547315/what-are-the-build-settings-for-a-universal-iphone-and-ipad-application) – Brad Larson Nov 18 '11 at 16:34

5 Answers5

4

First step: Upgrade your Xcode. Second: open your application and change the target's "Devices" to "Universal". Xcode may prompt you to create XIBs for iPad by autoresizing - do this if you can, otherwise create the XIBs for iPad. I generally find it best to have a base class, and then two subclasses that contain functionality overrides - e.g.

@interface ViewController : UIViewController
@end

@interface ViewController_iPad : ViewController
@end

@interface ViewController_iPhone : ViewController
@end
Benjie
  • 7,701
  • 5
  • 29
  • 44
  • +1 for the suggestion of inheritance. Although in my case I could implemented the same without upgrading my xcode. – Naved Nov 01 '11 at 08:36
  • @Benjie Gillam can u explen in detail more please i think ur ans is work for me friend i never create till this type of application please help me in detail if u can – Rocky Nov 01 '11 at 08:37
  • @Naved Upgrading Xcode gives you a lot better tools to deal with universal apps, in my opinion. – Benjie Nov 01 '11 at 08:41
  • @Rocky Please let me know exactly which part you are stuck on? – Benjie Nov 01 '11 at 08:42
  • @BenjieGillam how to start for making this i not have any idea of this can u tell from start point how to make autoresizing and create the xibs for ipad in same application which work for iphone – Rocky Nov 01 '11 at 08:46
  • In Xcode, find your target settings for your application, find the entry "Devices" and change the drop-down to "Universal". – Benjie Nov 01 '11 at 08:51
  • Here's a better way of doing it: http://stackoverflow.com/questions/5580935/converting-iphone-app-to-a-universal-app-in-xcode-4 – Benjie Nov 01 '11 at 08:59
1

We recently used this template and we simply loved it! Lets u avoid IDIOM checks and the inheritance allows code reuse.

Manali
  • 577
  • 4
  • 11
  • This looks really interesting but how does it work? I don't see any code indicating that either the iPhone or iPad code paths should be followed. Is there documentation on this approach anywhere? Thanks. – Rich Everhart May 02 '12 at 23:21
  • In the info.plist file you will find entries for iphone and ipad mainwindow.xib files. At run time OS decides which to load according to platform available. I cannot look at the code right now, but I believe it has two platform specific app delegates deriving from a common one. – Manali May 03 '12 at 14:30
0

To build universal app for both iPhone and iPad, I highly suggest to give up IB/XIB/Storyboard, prefer to create any UI components with code directly. We can use the macro to check which device and just use the same macro for full screen etc. I know some people would prefer IB because it is easy to see what they built, but that will bring a bit efforts for different XIB version.

Forrest
  • 122,703
  • 20
  • 73
  • 107
0

To make your apps universal for devices like iPhone and iPad, you need to make duplicates of the code most of the time. If you are using XIB, make for both iPhone and iPad. Use IDIOM checks whenever required to avoid creation of duplicate classes (i.e. the classes containing duplicate logic).

For detail, you can refer this link How to make Universal Apps

Naved
  • 4,020
  • 4
  • 31
  • 45
  • where i have to put this idom checks can u help me on this and what to do in this please tell me – Rocky Nov 01 '11 at 08:42
  • You can decide the display (UI) for iPhone or iPad in your .m file. Like "if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)". – Naved Nov 01 '11 at 08:45
  • can u provid some sample code on this just for helloworld eg code like for run on both iphon,ipad – Rocky Nov 01 '11 at 08:49
  • I think, if you follow the Link as in my answer, you will get the idea. – Naved Nov 01 '11 at 10:24
0

http://useyourloaf.com/blog/2010/4/7/converting-to-a-universal-app-part-i.html

ader
  • 5,403
  • 1
  • 21
  • 26
  • 1
    While this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bill the Lizard Nov 02 '11 at 20:35
  • Understood. But people should also try searching before asking questions. Maybe it would be preferable for me not to bother answering trivial many times before asked questions. – ader Nov 07 '11 at 11:11