Multi-Platform Support for the iPhone and iPad.

来源:转载

Copy from Beginning iOS 4 Application Development,author:Wei-Meng Lee, Microsoft MVP ,come from Singapore.

  • technique 1 — mODifying the Device tArget Setting

The Targeted Device Family setting provides three different values: iPhone, iPad, or iPhone/iPad.

#if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 30200)

    //---code within this block will be compiled if application is compiled

    // for iPhone OS 3.2 and above---

#endif

  • technique 2 — creAting univerSAl ApplicAtiOnS

Apple recommends that you create a Universal application, one that targets both the iPhone and the iPad, with separate XIB files representing the UI for each platform.

in Xcode, select Targets Universal. Then select Project Upgrade Current Target for iPad .
In the dialog box that appears, check the One Universal application option and click OK

  • technique 3 — mAintAining twO cODe BASeS

The third technique for developing your application for multiple devices is to maintain separate targets for your application.
Using this approach, you will have two executables eventually one for the iPhone/iPod touch, and one for the iPad.
The following steps explain how to accomplish this.

  1 .  Using Xcode, create a View-based Application (iPhone) project and name it MyAppiPhone.
  2 .  Select Targets MyAppiPhone, and then select Project  Upgrade Current Target for iPad.
  3 .  In the dialog box that appears, select the Two device-specific applications option and click OK .


mAking yOur chOice
Now that you have seen the three techniques for porting your iPhone application to support the iPad, which technique should you adopt?
If your application does not have many UI changes when running on either the iPhone or iPad,
using the first technique (modifying the device target setting) is the easiest way to support two platforms with a single code base and a single UI.
All you need to do is to ensure that when the application runs on the iPad, the UI is rearranged correctly this can be done programmatically in your View Controller.

Most developers should benefit from creating Universal applications.
When you have an application that supports two different platforms,
creating a Universal application allows you to have one code base and several XIB files designed specifically for the iPhone and iPad.
This technique and the first save you the trouble of uploading two different editions of your application to AppStore.
You need to upload just one version of your application and it will automatically support both platforms.

The last technique, maintaining two different code bases, is useful if your application behaves differently when it is running on different platforms.
When your application does not support certain features while running on the iPhone, you might have quite a different code base for each platform.
In this case, maintaining different code bases might be a better idea and save you the trouble of bundling all the unnecessary files into a single application.

南来地,北往的,上班的,下岗的,走过路过不要错过!

======================个性签名=====================

之前认为Apple 的iOS 设计的要比 Android 稳定,我错了吗?

下载的许多客户端程序/游戏程序,经常会Crash,是程序写的不好(内存泄漏?刚启动也会吗?)还是iOS本身的不稳定!!!

如果在Android手机中可以简单联接到ddms,就可以查看系统log,很容易看到程序为什么出错,在iPhone中如何得知呢?试试Organizer吧,分析一下Device logs,也许有用.


对于博客园里的网友,不敢称为叫"程序员"的人,你们攻击性太强,看来你们是不会想到我的用意的.园子里有不少人都非常喜欢Jeffrey,是因为它的第一版 框架设计 CLR via C#.
可是从第一版到现在的第三版,没有看到真正底层的东西,内容仅仅是比MSDN文档更丰富一些,可能是我的要求太高了吧.
也就是因为它很多时候会接触到微软开发人员,会经常聊聊某些问题而已,而它又将这些问题反应到书中.也许它就像一个小记者.
它的年龄大我们不多,我的孩子与它小儿子一般大,如果我能向它那样出入微软与它们开发人员长时间交流,不仅仅会牛成它这样.....
可是微软的开发人员不会扔太多时间在它这儿的.所以它会整天追着这个,赶它那个..屁颠个不停吧...
而它的另一版被称为好书的 Windows核心编程,更是没有什么深度可言,仅仅是将windows提供的api,以及内核功能再重申了一遍.
这些书对晋及编程知识是有些贡献的,再说一遍我不是在匾低谁,说说想法而已.


分享给朋友:
您可能感兴趣的文章:
随机阅读: