Resolution issues in Apple devices

Source: Internet
Author: User

In the application development of Apple devices, we often need to deal with screen resolution issues, including normal screens and retain screens.

When you work with screen resolution, you can divide it into point resolution and pixel (PIXER) resolution. When we look at the device parameters, we see the pixel resolution generally, because it is larger and looks taller. Next, let's take an example of an iphone device to see how the point resolution and pixel resolution are handled separately in development.

First, create a single view app under iOS in Xcode, and then create the relevant code in the Viewdidload method in the VIEWCONTROLLER.M. application file.

The following code shows the point resolution of the current device.

Cgsize size = [[UIScreen mainscreen] bounds].size; NSLog (@ "Points:width (%f), height (%f)",     Size.width, size.height);

If the device being tested uses the Retain screen, the above code shows that the data is much lower than the identified resolution parameter, and the following code shows the full pixel resolution.

Cgsize size = [[UIScreen mainscreen] bounds].size;float scale = [UIScreen mainscreen].scale; NSLog (@ "Pixers:width (%f), height (%f)",     size.width * scale, size.height * scale);

In the second piece of code, we used the screen's scale property, whose value is the point-to-pixel relationship. If the scale value is 1, the device does not use the retain screen, and if it is greater than 1, the device uses the Retain screen, or if the scale property value is 3, a point on the screen contains 9 (3*3) pixels (pixer).

In general, it is possible to use only point coordinates in the interface development of an iOS or MacOS system, which simplifies many coordinate processing tasks. Note that the Uikit interface's origin (0,0) is in the upper-left corner, while the interface origin in Spritekit is in the lower-left corner.

Resolution issues in Apple devices

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.