I'm really confused as to how iOS Ruler apps currently on the market are compatible with different size devices. An example is shown at the bottom.
After researching, I had come to the conclusion that getting the PPI of the current screen in realtime was impossible, which makes it impossible to programmatically draw a ruler.
My query is how do these ruler apps accurately display a ruler without being able to get the device PPI?
My first thought would be that the PPI and screen size for each device is hard-coded into the app. This seems like a lot of effort and a recipe for a million mistakes. Is this really how they have to do it? It would need to be tested on each different device to ensure it works correctly. I only have access to my iPhone 5S. Might they have different images of rulers for each different device? This would take up a lot of space on the phone.
I've seen similar questions on SO about drawing rulers, but (correct me if I'm wrong) they don't seem to have a solution for maintaining accuracy for different screen sizes and PPI. They all seem to say "it's impossible". If it's impossible, how is it done?
Like most (but not all) measuring apps, Apple's Measure is not designed for precision measurements: while we've found it to be pretty accurate for measuring physical objects and the odd child, it's not as accurate as the laser measures or good old-fashioned tape measures that professional tradespeople use.
The Measure app uses augmented reality (AR) technology to turn your device into a tape measure. You can gauge the size of objects, automatically detect the dimensions of rectangular objects, and save a photo of the measurement.
You can show a ruler at the top of the screen to set paragraph margins, set tab stops, and help position text boxes and other objects.
As you have discovered, iOS has no public API for getting the device's PPI.
These apps probably have a hardcoded list, as you speculated. There are under a hundred hardware device ids (see this list for example), and only a handful of different PPIs:
I'd guess the makers of these apps don't usually test their apps with every device. And unless you've checked the apps, there's no reason you should believe the apps are more accurate than the PPIs listed above.
To detect the iOS device type, check the answers to this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With