相关疑难解决方法(0)

如何判断您的代码是在iPhone还是iPhone3G上运行?

我试图确定我的代码是在iPhone还是iPhone3G上运行.我的第一次尝试是在UIKit中使用UIDevice类,但iPhone和iPhone3G都返回相同的响应:

NSLog([[UIDevice currentDevice] name]); // Name of the phone as named by user
NSLog([[UIDevice currentDevice] uniqueIdentifier]); // A GUID like string
NSLog([[UIDevice currentDevice] systemName]); // "iPhone OS" 
NSLog([[UIDevice currentDevice] systemVersion]); // "2.2.1"
NSLog([[UIDevice currentDevice] model]); // "iPhone" on both devices
NSLog([[UIDevice currentDevice] localizedModel]); // "iPhone" on both devices
Run Code Online (Sandbox Code Playgroud)

这些是UIDevice允许您查询的唯一参数.

我在Foundation Framework中看了一下,但还没有找到合适的电话.

我敢肯定有一些我可以查询的硬件(例如位置服务中的东西),但这似乎是一个黑客.有谁知道确定这个的简单方法?

iphone ios

22
推荐指数
2
解决办法
5134
查看次数

如何确定当前设备是iPhone还是iPad?

在我的通用应用程序中,我需要检查当前设备是iPad还是iPhone.我该如何以编程方式执行此操作?我打算把代码放在我的viewDidLoad中.

iphone xcode objective-c ipad ios

2
推荐指数
1
解决办法
4683
查看次数

标签 统计

ios ×2

iphone ×2

ipad ×1

objective-c ×1

xcode ×1