iPhoneとiPadの判別
端末の判別に[[UIDevice currentDevice].model
を使用する事がありますが、このやり方だとiPhone, iPad, iPodTouch, iPhone Simulator, iPad Simulatorの値が返ってくるため、単純にユニバーサルアプリ等でiPhone, ipadの判別をしたい場合は処理が煩雑になったりします。
ここは素直にUniversalアプリのテンプレに従って
[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone
[[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
で判別し、例えば
#define is_iPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ? YES:NO)
このようなマクロを設定しておくのが良さそう。
使用例
#define is_iPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ? YES:NO) NSLog(@"iPad=%d",is_iPad); //iPhone iPad=0 //iPad iPad=1