Best way for creating universal native iPhone/iPad application?

不羁岁月 提交于 2019-12-11 15:02:35

问题


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

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

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

Thanks, Ajay


回答1:


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.

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



来源:https://stackoverflow.com/questions/6666514/best-way-for-creating-universal-native-iphone-ipad-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!