通过UIDevice的UIUserInterfaceIdiom属性来区分:
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
} else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
}
或者直接使用以下
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) //iPad
{
}
else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) //iPhone
{
}
static inline这个可以了解一下。