xcode 将简单的 iPhone 应用程序转换为通用应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5861330/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:57:35  来源:igfitidea点击:

Convert simple iPhone app to Universal app

iphonexcodeiosipaduniversal

提问by Tunyk Pavel

I have very simple iPhone app, which uses just UIButtons, UIlabels, UITableView. without any custom controllers and graphics. How can I convert app to universal with that UI?

我有一个非常简单的 iPhone 应用程序,它只使用UIButtons, UIlabels, UITableView。没有任何自定义控制器和图形。如何使用该 UI 将应用程序转换为通用应用程序?

回答by Black Frog

First update the application target device to Universal.

首先将应用程序目标设备更新为 Universal。

  1. Update the application target device to Universal.
  2. Check the Info.plist for NSMainNibFile& NSMainNibFile~ipadkeys.
  3. For all other views, have two different NIB. For example FirstView.xib & FirstView~ipad.xib. iOS runtime will load the proper view based on the device.
  1. 将应用程序目标设备更新为 Universal。
  2. 检查 Info.plist 中的NSMainNibFile&NSMainNibFile~ipad键。
  3. 对于所有其他视图,有两个不同的 NIB。例如 FirstView.xib & FirstView~ipad.xib。iOS 运行时将根据设备加载正确的视图。

Here is a screenshot of a sample project: Info.plist for iOS Universal app

这是示例项目的屏幕截图: iOS 通用应用程序的 Info.plist

回答by jroyce

I needed to convert my iPhone App to iPad yesterday and found the easiest way to do it as long as your app is pretty simple. Mine was literally just some tableViews that were set to auto-size. In Targets / Devices just change it from 'iPhone' to 'Universal' and then build your application. This worked very nicely for me. All tableViews were perfectly formatted for the iPad and that is really all I needed.

昨天我需要将我的 iPhone 应用程序转换为 iPad 并找到了最简单的方法,只要您的应用程序非常简单。我的实际上只是一些设置为自动调整大小的 tableView。在目标/设备中,只需将其从“iPhone”更改为“通用”,然后构建您的应用程序。这对我来说非常有效。所有 tableViews 都为 iPad 完美格式化,这真的是我所需要的。

Note that if you had any other XIB files that were not just tableViews, such as a window with text fields, all you have to do is set them each to resize properly so they stretch and stay at the top and your simple app should be pretty much all set for the iPad.

请注意,如果您有任何其他不仅仅是 tableViews 的 XIB 文件,例如带有文本字段的窗口,您所要做的就是将它们设置为正确调整大小,以便它们拉伸并保持在顶部,并且您的简单应用程序应该很漂亮为 iPad 设置了很多。

Obviously you'll need to test it and tweak anything needed but for the most part the above worked magically for me and took literally one second to convert my iPhone app to an iPad app!

显然,您需要对其进行测试并调整所需的任何内容,但在大多数情况下,上述方法对我来说神奇地工作,并且花了一秒钟时间将我的 iPhone 应用程序转换为 iPad 应用程序!