简体   繁体   English

通用iPhone / iPad应用程序

[英]Universal iPhone/iPad application

I know, how to detect whether it iPhone or iPad 我知道,如何检测是iPhone还是iPad

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 

I know 2 ways to build universal app: 我知道两种构建通用应用程序的方法:

1) use one controller for 2 xibs (iPhone/iPad) 1)将一个控制器用于2个xib(iPhone / iPad)

2) use different viewcontrollers for iPad and iPhone 2)为iPad和iPhone使用不同的ViewController

What's the best way to do that? 最好的方法是什么?

Same View Controllers for iPhone & iPad, but using UIUserInterfaceIdiom as switch case to avoid duplicated view controllers ( with same contents ) created. 适用于iPhone和iPad的相同视图控制器,但使用UIUserInterfaceIdiom作为开关盒,以避免创建重复的视图控制器(内容相同)。

You can use different XIBs for iPhone & iPad though. 不过,您可以为iPhone和iPad使用不同的XIB。

I think use different XIBs is better because use different view controllers means you have to main two almost same code. 我认为使用不同的XIB更好,因为使用不同的视图控制器意味着您必须维护两个几乎相同的代码。 And on the XIB you can clearly see what you will get using that XIB for iPhone or iPad. 在XIB上,您可以清楚地看到将XIB用于iPhone或iPad会得到什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM