Needs
I want to turn off the screen when the user places his iphone upside down on the q-table. At the same time, I do not want the proximity monitor to turn on all the time, as this is very inconvenient for the user and repeatedly passes lights depending on how you capture the device.
What for
This should go away at night and save battery and screen time when working with the application.
Workaround
I am thinking of using an accelerometer to determine if a person is down, if so activate censorship of intimacy. Simple stuff ...
Problem
In practice, the workaround does not work, it says that if the censor is “clogged” when you activate it, it will not register its current state.
Refresh UIDevice somehow?
What i use
-(id)init { if ((self = [super init])) { NSLog(@"Init ShakerAnalizer"); accelerometer = [UIAccelerometer sharedAccelerometer]; accelerometer.delegate = self; accelerometer.updateInterval = 5.0f; } return self; } -(void)accelerometer:(UIAccelerometer *)accel didAccelerate:(UIAcceleration *)acceleration { if (accelerometer) { NSLog(@"Accelerometer Z::: %f", acceleration.z); if (acceleration.z > kFlippedThreshold) device.proximityMonitoringEnabled = YES; else device.proximityMonitoringEnabled = NO; } }
source share