Post

Replies

Boosts

Views

Activity

Proximity sensor in landscape
I'm developing an app for virtual headset (cardboard).I want to detect when iphone has been enclosed in the cardboard by using the proximity sensor.Problems:once [[UIDevice currentDevice] proximityState] == YES the screen goes black, while I need to show images.the proximity notification is generated only in portrait mode. I need it (only) in landscape mode.Here my code:- (void)viewDidLoad { [super viewDidLoad]; [[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proxSensorStateMonitor:) name:UIDeviceProximityStateDidChangeNotification object:nil]; [[UIApplication sharedApplication] setIdleTimerDisabled:YES]; } - (void)proxSensorStateMonitor:(NSNotificationCenter *)notification { if ([[UIDevice currentDevice] proximityState] == YES) { [[UIDevice currentDevice] setProximityMonitoringEnabled:NO]; // Provide content for Cardboard } }
1
0
1.1k
Feb ’16