iphone - 如何检测主机设备是iPhone还是iPad?

标签 iphone cocoa-touch ios4 device

Possible Duplicate:
Best way to programmatically detect iPad/iPhone hardware

我正在准备一个应用程序,我想在 iPhone 和 iPad 上使用它。

如何检测当前主机设备是iPhone还是iPad?

基于此我想对用户界面进行更改

最佳答案

有很多方法可以找到应用程序正在哪个设备上运行。

[[[UIDevice currentDevice] systemVersion] floatValue];

通过此代码我们可以获取当前设备的版本,以便我们可以检查该设备是否是iPhone或iPad。

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    // iPad-specific interface here
}
else
{
    // iPhone and iPod touch interface here
}

关于iphone - 如何检测主机设备是iPhone还是iPad?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4343088/

相关文章:

ios - 为什么 UICollectionView reloadData 会导致我的应用崩溃?

iphone - 以编程方式将函数锚定到 UIButton

iphone - 如何将欢迎屏幕插入我的基于导航的 iPhone 应用程序?

iphone - 如何创建自定义页面 curl 核心动画?

iphone - Tableview 线显示槽加载 View

iphone - 如何本地化数组中的所有字符串

ios - NSPhotoLibraryAddUsageDescription 错误

iphone - startMonitoringSignificantLocationChanges 未触发?

php - 使用 GD 为 iPhone OS 4.1 编译 PHP

iphone - 如何在 iPhone 中本地打开 .doc 文件?