我有一个带有接口的UIViewController类,当它在iPhone-5上运行时,我希望它不同,如何在我的代码中获得iPhone类型?
发布于 2012-11-19 14:28:20
你可以使用下面的代码来检查它的iPhone5。首先在.m文件中定义以下代码。
#define IS_IPHONE_5 ( [ [ UIScreen mainScreen ] bounds ].size.height == 568 )然后使用以下条件
if( IS_IPHONE_5 )
{
// Running in iphone 5
}
else
{
// Running in other iphone
}发布于 2012-11-19 14:34:27
您只需在AppDelegate中设置以下代码...
int deviceType;
float height = [UIScreen mainScreen].bounds.size.height;
if (height==568) {
self.deviceType = 5;
}
else
{
self.deviceType = 4;
}下面是您想要在xcode类中的任何位置使用的代码
if(appdelegate.deviceType == 5){
iPhone 5 Code...
}
else{
iPhone 4 code
}https://stackoverflow.com/questions/13448649
复制相似问题