//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デバイス
このコードは、デバイスが存在するかどうか( 'isProximityMonitoringEnabled')ではなく、デバイスが何か(' proximityState')に近いかどうかをチェックします。 –