创建通用原生iPhone / iPad应用程序的最佳方式? [英] Best way for creating universal native iPhone/iPad application?

查看:153
本文介绍了创建通用原生iPhone / iPad应用程序的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪种方法适合为iPhone / iPad创建通用本机应用程序:

Which approach is good to create universal native application for iPhone/iPad:

1)为iphone和iPad版本创建单独的NIB文件,并通过检查加载特定版本(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad)

1) Create separate NIB files for iphone and iPad versions and load the specific version by checking (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad).

2)获取主屏幕的尺寸并相应地构图视图

2) Get the dimension of the main screen and frame the view accordingly

CGRect mainWindow = [[UIScreen mainScreen] bounds];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, mainWindow.size.width, mainWindow.size.height)];

如果我错过任何其他方法,请建议

Please suggest if any other approach that I missed

谢谢,
Ajay

Thanks, Ajay

推荐答案

我使用第一种方法,在很多情况下,至少对我而言自己设置自动调整掩码就足够了。你还没有说过这个,但是如果你的应用程序看起来几乎一样(扩展的布局),这个工作正常。在我需要另一种布局的情况下,我检查了它是否是iPad / iPhone并加载了正确的NIB,或者使用基于设备的 loadView 中的GUI代码。

I am using the first approach, in many cases, at least for my own it is sufficient to set autoresizing masks. You have not said anything about this, but if your application will look pretty much the same (up-scaled layout) this works fine. In the cases I need another layout I have checked whether it is an iPad/iPhone and loaded the correct NIB, or used the GUI code in loadView based on the device.

使用webview的示例代码,您可以使用自动调整大小的掩码,当帧更改时,它会调整为正确的比例。

From you example code with the webview you could use autoresizing masks and it would resize to the correct proportions when the frame changes.

这篇关于创建通用原生iPhone / iPad应用程序的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆