iPhoneかiPadかと画面の高さで判別します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
// iPhone
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){
// iPhone4 or 4S
NSLog(@"iphone 4, 4s retina resolution");
}
if(result.height == 1136){
// iPhone5
NSLog(@"iphone 5 resolution");
}
}
else{
// iPhone4より古い機種
NSLog(@"iphone standard resolution");
}
}
else
{
// iPad
if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {
// iPad retina
NSLog(@"ipad Retina resolution");
}
else{
// iPad,iPad2
NSLog(@"ipad Standard resolution");
}
} |