我需要检测IOS8上运行的iphone 5和iphone 6。我使用下面的代码,但这只适用于ios7。如何更改此功能才能在ios8上运行?我有权访问xcode 5,无法升级到xcode 6.
- (BOOL)isCurrentDeviceiPhone5{
BOOL value = NO;
printf("\nDetected Resolution : %d x %d\n\n",(int)[[UIScreen mainScreen] bounds].size.width,(int)[[UIScreen mainScreen] bounds].size.height);
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
{
CGSize result = [[UIScreen mainScreen] bounds].size;
CGFloat scale = [UIScreen mainScreen].scale;
result = CGSizeMake(result.width * scale, result.height * scale);
if(result.height == 960 || result.height == 480){
value = NO;
}else if(result.height == 1136){
value =YES;
}
}
}else{
printf("Device Type : iPad");
value = NO;
}