检测在兼容模式下在iPad上运行的iPhone应用程序 [英] detecting iPhone app running on iPad in compatibility mode

查看:297
本文介绍了检测在兼容模式下在iPad上运行的iPhone应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程式( http://hexalex.com )不是通用的,但它有一个功能, d喜欢让人们在iPad上玩。有没有什么方法来检测你在兼容模式下在iPad上运行?用于检测机器规格的UIDevice方法都返回您将在iPhone上获得的值(至少在模拟器上)。

解决方案

最初在这里回答问题: http://stackoverflow.com/a/14864400/577237



由于时间太短,重新发布:



如果应用程序是在iPad上以模拟器模式运行的iPhone应用程序,则它将具有PhoneInterfaceIdiom,模型类型的iPad。您可以使用以下代码检查:

  if(UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPhone&& 
[ [[UIDevice currentDevice] model] hasPrefix:@iPad]){
//此应用程序是在iPad上运行的iPhone应用程序
}
pre>

My iPhone app (http://hexalex.com) is not universal but it has a feature that I'd like to enable for people playing on iPads. Is there some way to detect that you're running on an iPad in compatibility mode? The UIDevice methods for detecting machine specs all return the values you would get on an iPhone (on the simulator at least). The only thing I can think of is detecting OS 3.2, but that technique won't work for long.

解决方案

Originally answered here: http://stackoverflow.com/a/14864400/577237

Reposted since it's so short:

If the app is an iPhone app running in the emulator mode on an iPad, it will have a userInterfaceIdiom of Phone, but a model type of iPad. You can check this with the following code:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone &&
    [[[UIDevice currentDevice] model] hasPrefix:@"iPad"]) {
    // This app is an iPhone app running on an iPad
}

这篇关于检测在兼容模式下在iPad上运行的iPhone应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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