#if 判断条件
不用#if:
NSString*deviceType =[UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"]){
//iPhone
}
elseif([deviceType isEqualToString:@"iPod touch"]){
//iPod Touch
}
else{
//iPad
}
使用#if:
#ifdefUI_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

浙公网安备 33010602011771号