Beware: proximity sensor doesn't work in landscape


#1

All my code looked right but the proximity state changes weren’t being fired. It turns out that the proximity sensor only works in portrait mode, which is a bit unfortunate as the previous page gets us to make the app run only in landscape mode.


#2

Thanks! That certainly helped out a bit. I was able to confirm your findings that the proximity sensory is indeed disabled in landscape mode.


#3

Hi,

You can get it to work in Landscape if you force the status bar to portrait

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];

this may mess up the look of your view but can still come in handy.

I’ve used this in my app so that you can put the device face down (UIDeviceOrientationFaceDown) to save battery life.

Gareth