让 iPad 应用程序成为通用应用程序
我有一个 iPad 应用程序,我想使其通用,但这似乎非常困难。我已经改变了一些事情,以便支持这两种构建,但是在构建时,我遇到了很多关于使用 UIPopOvers 的错误。我的问题是:
- 为什么
UI_USER_INTERFACE_IDIOM()
无法在 3.1.3 上编译或注册? - 我可以有条件地在基于
UI_USER_INTERFACE_IDIOM()
的类定义中包含变量吗? - 如果没有,我应该制作两个不同的视图控制器吗?
谢谢!
I have an iPad app that I would like to make Universal, however this seems alarmingly difficult. I've changed things around so that I support both builds, but when building, I get lots of errors about using UIPopOvers. Here're my questions:
- Why does
UI_USER_INTERFACE_IDIOM()
not compile or register on 3.1.3? - Can I conditionally have variables in a class definition based on
UI_USER_INTERFACE_IDIOM()
? - If not, should I make two different view controllers?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UI_USER_INTERFACE_IDIOM
宏仅从 3.2 开始可用。 UIDevice。这意味着您只能从 SDK 3.2 开始获得通用应用程序。不可以。
UI_USER_INTERFACE_IDIOM
宏只是获取设备当前 UI 习惯用法的运行时快捷方式。如果两个设备之间的 UI 非常不同,那么更明智的做法是使用两个不同的视图控制器,并使用
UI_USER_INTERFACE_IDIOM
宏在运行时(例如在应用程序控制器中)创建正确的视图控制器。The
UI_USER_INTERFACE_IDIOM
macro is only available starting with 3.2. Same restrictions for theuserInterfaceIdiom
property of UIDevice. This means that you can only get universal application starting with SDK 3.2.No. The
UI_USER_INTERFACE_IDIOM
macro is only a runtime shortcut to get the current UI idiom of the device.If you have very different UI between the two devices, it is wiser to use two different view controllers, and to create the right one at runtime (in the application controller for example) by using the
UI_USER_INTERFACE_IDIOM
macro.我很幸运,只选择了目标,然后转到“项目”->“升级 iPad 的当前目标”。
我的应用程序非常简单,主要由表视图和 Web 视图组成,但值得进行备份并尝试...
是的,您必须将其作为可以针对 3.1 的 3.2 应用程序提交。*
还有很多其他 应用程序你必须做的事情:
确保它可以在任何方向查看(第一次被拒绝)。
确保您已创建所有新图像。你必须有 3 或 4 个图标,而不是像 iPhone 应用程序那样只需要一个。 (iPad 图标、iPhone 图标、聚光灯小图标等)。
当然还有 iPad 大小的商店屏幕截图。
我用来测试它是 iPad 还是 iPhone 的一个非常好的方法是检查设备是否可以使用分割视图控制器,因为在可预见的将来,没有像 iPhone 这样屏幕小的设备能够使用分割视图控制器。视图控制器。我刚刚创建了一个函数来为我执行此操作:
然后在我的应用程序中的任何位置,我想根据设备显示不同的内容,我只需对其进行检查:
这比像我所看到的那样检查操作系统版本要好得多一些人建议。
I had pretty good luck with just selecting the target then going to Project->Upgrade current target for iPad.
My app is pretty simple, consisting mostly of table views and webviews, but it's worth making a backup and trying...
And yes, you have to submit it as a 3.2 app that can target 3.1.*
There are also a lot of other stuff that you have to do:
Make sure that it can be viewed at any orientation (got rejected the first time for this).
Make sure that you have all the new images created. you have to have 3 or 4 icons, instead of just one like an iPhone app needed. (iPad icon, iPhone icon, small icon for spotlight, etc).
And of course iPad sized screenshots for the store.
A really nice way that I use to test if it's an iPad or iPhone is to check if the device can use a split view controller, since for the forseeable future no device with a screen as small as an iPhone will be able to use the split view controller. I just created a function to do this for me:
Then anywhere in my app that I want to display something different depending on device, I just do a check for it:
This is a lot better than checking against OS version like I've seen some suggest.