由于某些原因,这是行不通的,因为我更新到最新的xcode iOS版8. doesn't认识 ([[UIScreen mainScreen] scale] == 2.0)
&([[UIScreen mainScreen] scale] == 2.0)&([[UIScreen mainScreen] bounds] .size.height == 568.0)not working
([[UIScreen mainScreen] bounds].size.height == 568.0)
// Indicates game is running on iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
CCLOG(@"Running on iPad");
// it doesn´t recognize this any more
if ([[UIScreen mainScreen] scale] == 2.0) {
CCLOG(@"Running on iPad Retina");
} else {
CCLOG(@"Running on iPad 2");
}
} else {
CCLOG(@"Running on iPhone");
// it doesn´t recognize this any more
if ([[UIScreen mainScreen] bounds].size.height == 568.0) {
CCLOG(@"Running on iPhone 5");
} else {
CCLOG(@"Running on iPhone 4/4S");
}
}
哪些设备你用在兼容模式下的应用程序?您是否在iPad Retina上试过这种'[[UIScreen mainScreen] scale] == 2.0'? – 2014-09-29 05:32:12
不要比较没有epsilon的浮点数;)。不知道,如果这是这里的错误,但你永远不应该这样做。 – HAS 2014-09-29 05:39:21
@WaqasRaja我尝试了所有模拟器... ipad 2,ipad air,ipad retina,iphone 4s,iphone 5,iphone 5s,iphone 6,iphone 6 plus。 当在ipad上运行时,他们都在iphone上运行ipad 2部分 ,他们都去iphone 4/4s部分。 – Chris79 2014-09-29 14:14:35