iOS距离传感器的简单使用
作者:
没有故事的我 | 来源:发表于
2017-10-26 17:43 被阅读0次// 打开距离传感器
[UIDevice currentDevice].proximityMonitoringEnabled = YES;
// 通过通知监听有物品靠近还是离开
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityStateDidChange:) name:UIDeviceProximityStateDidChangeNotification object:nil];
- (void)proximityStateDidChange:(NSNotification *)note
{
if ([UIDevice currentDevice].proximityState) {
NSLog(@"有东西靠近");
} else {
NSLog(@"有东西离开");
}
}
本文标题:iOS距离传感器的简单使用
本文链接:https://www.haomeiwen.com/subject/noikpxtx.html
网友评论