Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How to detect retina display
-
Hello,
Working on the project I found that I need to detect what type of the screen have device that running my code. And made this simple detector. Probaby it is not something big, but for me this is first bites of code that uses
objc
bindings. Hope you will find it usefulGrab the gist
isretina.py
or codefrom objc_util import * us = ObjCClass('UIScreen') if us.mainScreen().scale() == 2.0: print('Retina') elif us.mainScreen().scale() == 3.0: print('iPhone Plus') else: print('Non retina')
-
You could also use
scene.get_screen_scale()
for this (which is basically just a wrapper around[[UIScreen mainScreen] scale
) – nothing wrong with your code, just wanted to point out that it's not necessary to delve into ObjC for this. -
from objc_util import ObjCClass scale = ObjCClass('UIScreen').mainScreen().scale() print({2: 'Retina', 3: 'iPhone Plus'}.get(scale, 'Non retina'))