是否有一种全局方法可以将 iPhone 和 iPad 应用程序合并为通用应用程序?

发布于 2024-10-21 17:32:09 字数 444 浏览 1 评论 0原文

我写了一个 iPhone 应用程序。然后,我稍微改变了界面,添加了更高分辨率的图像,并制作了一个 iPad 版本。在一个完美的世界里,我希望任何购买 iPad 版本的人都可以免费获得 iPhone 版本(但反之则不然)。由于苹果似乎没有办法做到这一点(对吗??),我的下一个最喜欢的解决方案是以某种方式让 iPad 版本包含 iPhone 版本。

我知道我可以将 iPad 版本转换为“通用”版本,但由于应用程序的外观如此不同,这似乎是一个真正的痛苦。我有很多视图控制器,它们在两个版本之间几乎完全不同。有些方法是相同的,但只有30%左右。有没有一个简单的解决方案:

  • 检查设备是 iPhone 还是 iPad

    • 如果是 iPhone,则使用一组文件

    • 如果是 iPad,则使用不同的文件组

提前致谢!

I wrote an iPhone app. Then, I changed the interface a fair bit, added higher res images, and made an iPad version of it. In a perfect world, I would like for anyone who buys the iPad version to get the iPhone version for free (though not conversely). Since Apple doesn't seem to have a way to do that (right??), my next favorite solution is to make the iPad version include the iPhone version somehow.

I know that I could just convert the iPad version to "universal", but since the face of the app is so different, that seems like a real pain. I have many view controllers and they are almost completely different between the two versions. Some of the methods are the same, but only about 30%. Is there an easy solution along the lines of this:

  • Check if device is iPhone or iPad

    • If iPhone, then use one group of files

    • If iPad, then use a different group of files

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对风讲故事 2024-10-28 17:32:09

尝试在 Xcode 中创建一个新项目并选择使其成为通用应用程序。在 Xcode 的默认布局方式中,iPad 和 iPhone 版本之间存在明显的区别。您可以根据需要使应用程序的两个版本相似或不同。

此外,您可以使用 UI_USER_INTERFACE_IDIOM() 检查运行时正在运行的设备。目前,该值的两个值为 UIUserInterfaceIdiomPadUIUserInterfaceIdiomPhone

Try creating a new project in Xcode and choose to make it a universal app. In the default way Xcode lays it out, there is a distinct divide between the iPad and iPhone versions. You can make the two versions of the app as similar or different as you want.

In addition, you can check which device you are running on at runtime by using UI_USER_INTERFACE_IDIOM(). Currently the two values for this are UIUserInterfaceIdiomPad and UIUserInterfaceIdiomPhone.

聽兲甴掵 2024-10-28 17:32:09

您描述的“简单解决方案”基本上是 iOS 加载通用应用程序的方式。

没有其他真正的解决办法。您必须将两个项目再次合并为一个才能完成您想要的操作。

第一个问题是两个项目之间的一些(许多?)类名称是通用的。您可以通过使用 Xcode 中的“重构...”功能来更改一个项目(例如您的 iPhone 应用程序,因为它较旧)中的类名称,然后再将它们合并在一起,从而避免一些麻烦。第二个问题是你的Info.plist;您需要确保将正确的“主笔尖文件基本名称”、正确支持的界面方向、图标文件等分别设置为 iPad 和 iPhone 的正确值。

The "easy solution" you describe is basically how iOS loads Universal apps.

There's no other real way around it. You'll have to merge your two projects into one again to do what you want.

The first problem will be that some (many?) names of classes will be common between both projects. You can save yourself some pain by using the "Refactor..." functionality in Xcode to change the names of the classes in one project (say, your iPhone app, since it's older) before you merge them together. The second problem will be your Info.plist; you'll need to ensure that the correct "Main nib file base name", the correct supported interface orientations, icon files, and so on are set to correct values for both iPad and iPhone respectively.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文