フルスクリーンのグラデーション背景を持つ iOS アプリがあります。さて、iPhone 5 では画面サイズが異なり、もちろん 5 番目と 4 番目のデバイスの両方をサポートしたいと考えています。
おすすめのやり方とは?
フルスクリーンのグラデーション背景を持つ iOS アプリがあります。さて、iPhone 5 では画面サイズが異なり、もちろん 5 番目と 4 番目のデバイスの両方をサポートしたいと考えています。
おすすめのやり方とは?
コメントでリンクした投稿から
#import <sys/utsname.h>
NSString*
machineName()
{
struct utsname systemInfo;
uname(&systemInfo);
return [NSString stringWithCString:systemInfo.machine
encoding:NSUTF8StringEncoding];
}
結果は次のようになります。
@"i386" on the simulator
@"iPod1,1" on iPod Touch
@"iPod2,1" on iPod Touch Second Generation
@"iPod3,1" on iPod Touch Third Generation
@"iPod4,1" on iPod Touch Fourth Generation
@"iPhone1,1" on iPhone
@"iPhone1,2" on iPhone 3G
@"iPhone2,1" on iPhone 3GS
@"iPad1,1" on iPad
@"iPad2,1" on iPad 2
@"iPhone3,1" on iPhone 4
@"iPhone4,1" on iPhone 4S
これにより、最新モデルの @"iPhone5,1" のようなものが返されると想定しています。次に、次のようなチェックを行います
NSString *iphoneType = machineName();
if ([iphoneType isEqualToString@"iPhone5,1"]){
//image for iphone 5
} else {
//image for the rest
}
それがうまくいくかどうか教えてください