You can use orientation (using the XYZ values when the screen is face down). I do not recommend this, because your screen will fade out even if a user is using the app while lying down, and staring up at the screen.
There is an easier and cleaner way. Notice how during phone calls, having the phone close to your ear blacks out the screen?
You can access that property by monitoring the proximityState
property of UIDevice
. Details here
Doing something like:
BOOL closeToUser = [[UIDevice currentDevice] proximityState];
will assign a YES
to closeUser when the device is face down on a surface of some kind, and a NO
when it is not
If the value is YES, you can invoke code to do whatever you want.