我想检查iOS设备的版本是否大于3.1.3
我尝试过的东西:
[[UIDevice currentDevice].systemVersion floatValue]
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我只想要一个:
if (version > 3.1.3) { }
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我在iOS 7和iOS 8中运行了以下代码:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight);
NSLog(@"Currently landscape: %@, width: %.2f, height: %.2f",
(landscape ? @"Yes" : @"No"),
[[UIScreen mainScreen] bounds].size.width,
[[UIScreen mainScreen] bounds].size.height);
Run Code Online (Sandbox Code Playgroud)
以下是iOS 8的结果:
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 568.00, height: 320.00
Run Code Online (Sandbox Code Playgroud)
与iOS 7中的结果相比:
Currently landscape: No, width: 320.00, height: 568.00
Currently landscape: Yes, width: 320.00, height: 568.00
Run Code Online (Sandbox Code Playgroud)
是否有任何文件指定此更改?或者它是iOS 8 API中的临时错误?
iPhone 6和6 Plus的平台字符串是什么?
仅供参考:平台字符串非常重要,因为它有助于识别硬件模型以进行编程.
以下是我的猜测:
我试图找出iOS中的PPI(Pixils Per Inch).
我找不到任何直接的方法来查询这个,就像我们对显示大小一样
UIScreen.mainScreen().bounds
Run Code Online (Sandbox Code Playgroud)
有一种方法可以通过将尺度与iPhone(163)或iPad(132)的标准通用PPI相乘来实现,但这并不准确.
如果公式是正确的那么PPI的iPhone 6 plus是489,但在现实的PPI为401这里是参考
现在似乎硬编码是要走的路.
但我想使用公式以编程方式进行.
ios ×4
uiscreen ×2
ios8 ×1
iphone ×1
iphone-6 ×1
objective-c ×1
orientation ×1
ppi ×1
swift ×1