thn*_*iss 0 iphone ipad ios-4.2
我知道iOS 4.2也适用于iPad.下面的代码是我们用于识别设备的标准模式.4.2 iPad将如何变化?我应该更改代码以考虑设备类型而不是版本吗?
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
CGRect frame = [[UIScreen mainScreen] bounds];
self.view.frame = frame;
#else
CGRect frame = [self.view bounds];
#endif
Run Code Online (Sandbox Code Playgroud)
更好的方法是[[UIDevice currentDevice] userInterfaceIdiom]
首先检查currentDevice是否响应该选择器.如果没有,那么它是运行iOS 3.1.x或更早版本的iPhone/iPod.
如果它确实响应了该选择器,那么您可以检查UIUserInterfaceIdiomPhone或UIUserInterfaceIdiomPad的结果.
| 归档时间: |
|
| 查看次数: |
1316 次 |
| 最近记录: |