what is the code to detect whether ios app running in iPhone, iPhone Retina display, or iPad?

前端 未结 5 1643
走了就别回头了
走了就别回头了 2021-01-02 06:03

what is the code to detect whether ios app running in iPhone, iPhone Retina display, or iPad?

Background:

  • for my iPhone application I have defined i

5条回答
  •  执念已碎
    2021-01-02 06:28

    You can use [[UIDevice currentDevice] userInterfaceIdiom] to determine whether you're running on an iPhone/iPod touch or an iPad.

    There's often no need to determine directly whether you're on a retina display because UIImage handles that automatically when you use imageNamed and append "@2x" to your high resolution image file names (see Supporting High-Resolution Screens in the Drawing and Printing Guide for iOS).

    If you really need to know which resolution the screen has, use UIScreen's scale method.

提交回复
热议问题