开发者

Whats the best way to create an iPhone and an iPad application simultaneously?

I have an iPhone app that I would like to port over to the iPad, but I would like to have as little duplication as possible.

How do people usually go about doing this?

In xcode can you have different targets for iPhone and iPad and perhaps do some pre-processor checks? Or is it best to simply have two separate projects altogether?

Note, Im NOT talking about running the iPhone app on the iPad, I mean creating a native 3.2 app...

EDIT

So it looks like creating a universal application is the way to 开发者_运维知识库go:

http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/StartingYourProject/StartingYourProject.html#//apple_ref/doc/uid/TP40009370-CH9-SW8

But what I still dont understand is how to select different NIB files based on your current deployment???

Thanks a lot


For minimal duplication, you can use one project, with 2 sets of .nib files, but one set of source code files which include run-time checks for the UIUserInterfaceIdiom differences.

If you want two (or more) apps instead of a Universal app, just create two targets containing only the appropriate .nib files, and #ifdef the run-time check results using a Preprocessor Macro define in each target's Build Settings to force iPhone or iPad idiom only.


The latest (3.2.3) Xcode auto-generates a Universal project which is a great starting point to see how to target iPad and iPhone in one Xcode project.

File > New Project > Window-based Application > Product : Universal

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜