判断运行在那种设备上: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}

 

相关文章:

  • 2022-01-22
  • 2021-06-11
  • 2022-02-03
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-30
  • 2021-06-22
  • 2022-12-23
  • 2021-12-22
  • 2022-02-18
  • 2021-08-18
  • 2021-10-10
相关资源
相似解决方案