Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been hunting this down for too long, and there doesn't seem to be an easy way to get the dpi. However, the documentation for <a href="http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIScreen_Class/Reference/UIScreen.html" rel="noreferrer">UIScreen</a> says an unscaled point is about equal to 1/160th of an inch.</p> <p>So, basically if you want the dpi, you could multiply the scale by 160.</p> <pre><code> float scale = 1; if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { scale = [[UIScreen mainScreen] scale]; } float dpi = 160 * scale; </code></pre> <p>(The if statement with respondsToSelector is to keep the code working for older versions of iOS that don't have that property available)</p> <p>According to Wikipedia, the iPhone is 163 dpi, an iPhone with a retina display is 326, and the iPad is 132. So the iPad's dpi isn't particularly accurate using this formula, although the iPhone's is pretty good. If you want more accuracy for known devices, you could hardcode the dpi for known devices, with a 1/160 ratio as a fallback for anything in the future.</p> <pre><code> float scale = 1; if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { scale = [[UIScreen mainScreen] scale]; } float dpi; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { dpi = 132 * scale; } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { dpi = 163 * scale; } else { dpi = 160 * scale; } </code></pre> <p>This isn't really ideal, and I wouldn't mind seeing a better solution myself, but it's the best I could find.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload