iPhone Proximity Sensor

后端 未结 13 1982
感动是毒
感动是毒 2020-12-01 00:47

Can the iPhone SDK take advantage of the iPhone\'s proximity sensors? If so, why hasn\'t anyone taken advantage of them? I could picture a few decent uses.

For examp

13条回答
  •  无人及你
    2020-12-01 01:25

    Just to update, this is possible.

    device = [UIDevice currentDevice];
    
    // Turn on proximity monitoring
    [device setProximityMonitoringEnabled:YES];
    
    // To determine if proximity monitoring is available, attempt to enable it.
    // If the value of the proximityMonitoringEnabled property remains NO, proximity
    // monitoring is not available.
    
    // Detect whether device supports proximity monitoring
    proxySupported = [device isProximityMonitoringEnabled];
    
    // Register for proximity notifications
    [notificationCenter addObserver:self selector:@selector(proximityChanged:) name:UIDeviceProximityStateDidChangeNotification object:device];
    

    As benzado points out, you can use:

    // Returns a BOOL, YES if device is proximate
    [device proximityState];
    

提交回复
热议问题