How do the right applications stay accurate on all devices?

I'm really confused about how iOS Ruler apps are currently compatible with devices of different sizes. An example is shown below.

After research, I came to the conclusion that obtaining the PPI of the current screen in real time was impossible, which makes it impossible to programmatically draw the line.

My request is: how do these linear applications accurately display the line, without being able to get PPI devices?

My first thought was that the PPI and screen size for each device are hardcoded in the application. It seems like a lot of effort and a recipe for a million mistakes. Is this really how they should do it? It must be tested on each of the different devices to ensure that it works correctly. I only have access to my iPhone 5S. Can they have different ruler images for every other device? This would take up a lot of space on the phone.

I saw similar questions about SO about drawing rulers, but (correct me if I'm wrong) they don't seem to have a solution to maintain accuracy for different screen sizes and PPIs. They all seem to say "this is impossible." If this is not possible, how to do it?

example

+5
ios objective-c swift
source share
1 answer

As you discovered, iOS does not have an open API to get a PPI device.

These applications probably have a hard list, as you expected. There are over a hundred hardware device identifiers (see this list , for example) and only a few different PPIs:

  • not Retina iPhone, iPod touch and iPad mini: 163 PPI
  • Retina iPhone (except 6+), iPod touch and iPad mini: 326 PPI
  • iPhone 6+: 401 PPI
  • non-retina iPad: 132 PPI
  • Retina iPad: 264 PPI

I would suggest that the creators of these applications do not usually test their applications on each device. And if you have not tested the applications, there is no reason to believe that the applications are more accurate than the PPIs listed above.

To determine the type of iOS device, check the answers to this question .

+5
source share

All Articles