iPhoneアプリで3.5インチ端末と4インチ端末を見分ける判定文
突貫だったので、このメソッドをAppDelegateに作成。 スクリーンサイズを取得して4インチかどうかを判定するだけの文。 これをif文の条件として使い、Viewの配置の考慮に使う。
判定分
-(BOOL)is4inchDisplay { CGSize screenSize = [[UIScreen mainScreen] bounds].size; if(screenSize.width == 320.0 && screenSize.height == 568.0) { return YES; }else{ return NO; } }
使い方
#import "AppDelegate.h" AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; if([appDelegate is4inchDisplay]){ //4インチ端末の場合の処理 }else{ //3.5インチ端末の場合の処理(正確には4インチ端末以外) }