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

 

 

NSString*deviceType =[UIDevice currentDevice].model;

if([deviceType isEqualToString:@"iPhone"]){
   
//iPhone
}
elseif([deviceType isEqualToString:@"iPod touch"]){
   
//iPod Touch
}
else{
   
//iPad
}
 
使用#if:
#ifdef  UI_USER_INTERFACE_IDIOM  
 //注意此处没有括号
//UI_USER_INTERFACE_IDIOM 是枚举类型结构体,内有
typedefenum {

#if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED

UIUserInterfaceIdiomPhone, // iPhone and iPod touch style UI 0

UIUserInterfaceIdiomPad, // iPad style UI 1

#endif

} UIUserInterfaceIdiom;

 

//而UI_USER_INTERFACE_IDIOM()是定义的宏

#define UI_USER_INTERFACE_IDIOM() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)]?[[UIDevice currentDevice] userInterfaceIdiom]:UIUserInterfaceIdiomPhone)
  #define IS_IPAD() (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
#else
 
#define IS_IPAD() (false)
#endif

#if UI_USER_INTERFACE_IDIOM()==0  //==UIUserInterfaceIdiomPhone
@implementationUINavigationBar(Custom height)

-(CGSize)sizeThatFits:(CGSize)size {
   
CGSize newSize =CGSizeMake(self.frame.size.width,44+BreadCrumbBarHeight-1);
   
return newSize;
}    
@end
#endif

 

 

 

判断当前ios版本是否等于5.0

#ifdef __IPHONE_5_0
  //if (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0){  
float version = [[[UIDevice currentDevice] systemVersion] floatValue]; if (version >= 5.0)
  { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillChange:) name:UIKeyboardWillChangeFrameNotification
object:nil]; } #else [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyBoardWillChange:) name:UIKeyboardWillShowNotification object:nil]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyBoardWillChange:) name:UIKeyboardWillHideNotification object:nil]; #endif