iOS开发怎么区别是iPhone还是iPad?或者其他

通过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这个可以了解一下。

猜你喜欢

转载自blog.csdn.net/morris_/article/details/80084240
今日推荐