//I have created below snippet to let the sensor to be detected.
-(void)addProximitySensorControl {
UIDevice *device = [UIDevice currentDevice];
device.proximityMonitoringEnabled = YES;
BOOL state = device.proximityState;
if(state)
NSLog(@"YES");
else
NSLog(@"NO");
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(proximityChanged:)
name:@"UIDeviceProximityStateDidChangeNotification"
object:nil];
}
在 iPhone 3GS 或更早版本中,proximityChanged: 方法被成功调用,但在 iPhone 4 中,当我从上方悬停对象时,传感器(屏幕)没有被检测到。任何想法伙计们?