设备判断

1.判断是否为ipad设备

#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 

NSString *modelString=[[UIDevice currentDevice] model]; NSLog(@"设备:%@",modelString); if ([modelString isEqualToString:@"iPhone"]|| [modelString isEqualToString:@"iPod touch"] ||[modelString isEqualToString:@"iPhone Simulator"]){ deviceType=IPHONE_MODEL; } else if([modelString isEqualToString:@"iPad"]){ deviceType=IPAD_MODEL; } 

 

2.判断是否为ipod touch 4/iphone 4的分辨率

#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO) 

你可能感兴趣的:(iOS)