如何检测设备是否是iPhone 5? [英] How to detect if the device is an iPhone 5?
本文介绍了如何检测设备是否是iPhone 5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何检测iPhone 5(宽屏设备)?
我正在尝试为现有的ios4项目添加一个新视图来处理新的iphone5屏幕尺寸。
I am trying to add a new view to an existing ios4 project to handle the new iphone5 screen size.
但是我没有在这里测试iphone我用来测试屏幕大小的代码是不工作的,只是想知道是否有另一种检测设备类型的方法??
However I dont have an iphone here to test on and the code I am using to test the screen size isnt working, just wondering if there is another way of detecting the device type??
NSLog(@"%f", [ [ UIScreen mainScreen ] bounds ].size.height);
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
if([UIScreen mainScreen].bounds.size.height == 568.0)
{
//move to your iphone5 storyboard
[self changeView:splashScreenBIGV viewH:splashScreenH animLength:SCREEN_CHANGE_ANIM_LENGTH];
}
else{
//move to your iphone4s storyboard
[self changeView:splashScreenV viewH:splashScreenH animLength:SCREEN_CHANGE_ANIM_LENGTH];
}
}
推荐答案
我的通用应用,外汇应用,我只是使用屏幕高度检测概念如下:
For my universal app, Forex App, I'm simply using the screen height detection concept like so:
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
if (screenSize.height > 480.0f) {
/*Do iPhone 5 stuff here.*/
} else {
/*Do iPhone Classic stuff here.*/
}
} else {
/*Do iPad stuff here.*/
}
这篇关于如何检测设备是否是iPhone 5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文