API来确定是否在iPhone或iPad上运行

API来确定是否在iPhone或iPad上运行,第1张

概述参见英文答案 > iOS detect if user is on an iPad                                    12个答案                            是否有一个API用于在运行时检查是否在iPhone或iPad上运行? 我可以想到的一种方式是使用: [[UIDevice currentDevice] model]; 并检测字符串 参见英文答案 > iOS detect if user is on an iPad                                    12个答案                            是否有一个API用于在运行时检查是否在iPhone或iPad上运行?

我可以想到的一种方式是使用:

[[UIDevice currentDevice] model];

并检测字符串@“iPad”的存在 – 这似乎有点脆弱。

在3.2 SDK中,我看到UIDevice也有一个属性,这是我真正想要的,但不工作前3.2(显然):

[[UIDevice currentDevice] userInterfaceIdiom];

有没有其他方法来检查@“iPad”的普遍应用程序的存在?

解决方法 Checkout UI_USER_INTERFACE_IDIOM

Returns the interface idiom supported by the current device.

Return Value
UIUserInterfaceIdiomPhone if the device is an iPhone or iPod touch or UIUserInterfaceIdiomPad if the device is an iPad.

07001

The type of interface that should be used on the current device

typedef enum {   UIUserInterfaceIdiomPhone,UIUserInterfaceIdiomPad,} UIUserInterfaceIdiom;
总结

以上是内存溢出为你收集整理的API来确定是否在iPhone或iPad上运行全部内容,希望文章能够帮你解决API来确定是否在iPhone或iPad上运行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1087573.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存