iOS开发:如何防止iPad在iPad模式下运行通用应用程序? [英] iOS Development: How can I prevent an iPad from running a universal app in iPad mode?

查看:127
本文介绍了iOS开发:如何防止iPad在iPad模式下运行通用应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进入iOS开发阶段,我创建了一个通用应用程序,它变成了一个仅限iPhone的应用程序。当它在iPad上运行时,它只是加载一个白色屏幕,因为还没有写入iPad代码。我想要的是它在iPad上以iPhone模式运行,如果它以某种方式最终在iPad上运行。我将目标设备系列属性设置为iPhone,这样可以防止它作为iPad应用程序在App Store中显示,但如果有人同时拥有iPad和iPhone,那么该应用程序最终可能会同步在iPad上,它只会加载白色屏幕,因为它会尝试在iPad模式下运行应用程序,它没有任何代码可以支持。在这种情况下,我更喜欢它实际上是在iPad上运行,但是在iPhone模式下。



我的问题是......


  1. 当iPad运行通用应用程序时,如何知道在iPhone模式下运行它还是执行iPad特定代码?

  2. 在通用应用程序中,它如何知道哪些代码是iPhone以及哪些代码是iPad?

  3. 如何阻止iPad尝试运行iPad代码,而是运行iPhone代码?

如果我听起来像一个总菜鸟,我道歉,但我是。非常感谢你的智慧!

解决方案

  1. 而iPad看起来到应用程序的Info.plist,对于UIDeviceFamily键,这是一个阵列。值1表示iPhone / iPod Touch,2表示iPad。如果有一个'1'但没有'2'那么你会得到模拟的iPhone环境。由于您的目标设备系列,此值会自动写入Info.plist。如果您认为已将其设置为iPhone但仍在进行iPad构建,请检查您是否只为一个构建配置设置了它。如果您真的有信心,请查看生产的应用包中的Info.plist。

  2. 您只需编写一个二进制文件即可在任一设备上正确启动。

  3. 只是不要瞄准iPad。


I'm diving into iOS development and I created a universal app that turned into an iPhone-only app. When it runs on the iPad, it just loads a white screen since there's no iPad code written yet. What I'd like is for it to run in "iPhone" mode on the iPad, if it somehow ends up on an iPad. I have the "Targeted Device Family" property set to "iPhone", so that should prevent it from showing up in the App Store as an iPad app, but if anyone owns both an iPad and an iPhone, then the app could end up synced to the iPad, at which point it will just load the white screen because it will try to run the app in iPad mode, which it doesn't have any code to support. In this situation, I prefer that it actually ran on the iPad, but in iPhone mode.

My questions are...

  1. When an iPad runs a universal app, how does it know to run it in "iPhone mode" or execute the iPad specific code?
  2. In a universal app, how does it know which code is iPhone and which code is iPad?
  3. How can I prevent the iPad from trying to run the iPad code and, instead, run the iPhone code?

I apologize if I sound like a total noob, but I am. Thanks so much for your wisdom!

解决方案

  1. The iPad looks into the application's Info.plist, for the UIDeviceFamily key, which is an array. The value '1' indicates iPhone/iPod Touch, '2' indicates 'iPad'. If there's a '1' but no '2' then you get the simulated iPhone environment. This value is written to the Info.plist automatically as a result of your 'Targeted Device Family'. If you think you've set it to iPhone but are still getting an iPad build, check you didn't just set it for one build configuration. Check the Info.plist within your produced app bundle if you want to be really confident.
  2. There's only one binary, which you write to launch correctly on either device.
  3. Just don't target the iPad.

这篇关于iOS开发:如何防止iPad在iPad模式下运行通用应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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