if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
//ipad
}else {
//iphone
}
利用宏定义区分iphone 模拟器和真机
#if TARGET_IPHONE_SIMULATOR
label . text = @"iphoneSimulator" ;
#elif TARGET_OS_IPHONE
label . text = @"iphoneDevice" ;
#endif
详细说明在文件TargetConditionals.h中
/*
File: TargetConditionals.h
Contains: Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone
Note: TargetConditionals.h in 3.4 Universal Interfaces works
with all compilers. This header only recognizes compilers
known to run on Mac OS X.
Copyright: (c) 2000-2008 by Apple Inc., all rights reserved.
*/