
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sensorStateChange:)
name:@"UIDeviceProximityStateDidChangeNotification"
object:nil];
-(void)sensorStateChange:(NSNotificationCenter *)notification;
{
if ([[UIDevice currentDevice] proximityState] == YES) {
NSLog(@"Device is close to user");
//在此写接近时,要做的操作逻辑代码
}else{
NSLog(@"Device is not close to user");
}
}




by: 发表于:2017-10-25 10:45:40 顶(0) | 踩(0) 回复
??
回复评论