iphone-sdk中的宏定义(一)
判断运行在那种设备上:UI_USER_INTERFACE_IDIOM()
UI_USER_INTERFACE_IDIOM() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone)
定义在UIKit库的UIDevice.h中,(ios3.2以下的系统中没有userInterfaceIdiom属性,所以用这宏判断)
(UIUserInterfaceIdiom)userInterfaceIdiom是一个枚举,包括:UIUserInterfaceIdiomPhone,UIUserInterfaceIdiomPad
用法:if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){//do something}