iOS 7、iPhone、接近传感器 [英] iOS 7, iPhone, Proximity Sensor

查看:30
本文介绍了iOS 7、iPhone、接近传感器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简短的问题,但它困扰了我整整一夜.我在这里几乎没有自己的应用程序(我只编写 Objective-C 并且我使用 ARC),如果我在 appDelegate 中编写 - 应用程序 didFinishLaunching...:

This is a short question but it was bugging me for a whole night. I have few of my own applications here (I write Objective-C Only and I use ARC) where if I write in appDelegate - application didFinishLaunching...:

[[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityStateChanged:) name:UIDeviceProximityStateDidChangeNotification object:nil];

我得到完全正常的响应.显示屏关闭,我收到通知更改了接近状态等.

I get perfectly normal response. Display turns off, I get notification with changed proximityState, etc.

现在,我有一个不是我的应用程序,我应该修改它(我有 Xcode 项目 - 源文件).我只应该基于proximitySensor 实现一些更改.我绝对无法启用proximityMonitoring?我正在做与其他应用程序相同的事情,但它只是不调用通知也不更改接近状态.最大的不同是这个应用程序的 appDelegate 是 .mm - 混合语言,但我真的不认为这应该是一个问题.

Now, I have application that is not mine and I should modify it (I have Xcode project - source files). I only should implement some changes based on proximitySensor. I am absolutely unable to enable proximityMonitoring? I am doing the same thing as in other applications but it is simply not calling the notification and not changing proximityState. Biggest difference is that this application's appDelegate is .mm - mixed language, but I really don't think this should be a problem.

是否有一些全局方法可以禁用传感器或仅禁用接近传感器?某些用于录制音频或播放音频的服务可以禁用接近传感器吗?任何线索都是金!我真的不明白是什么阻止了我启用此功能.为大家加油.

Is there some GLOBAL way to disable sensors or only proximity sensor? Can some service for recording audio or playing audio be able to disable proximity sensor? Any clue would be golden! I really don't understand what could be preventing me from enabling this feature. Cheers everyone.

推荐答案

FUU!

如果应用程序不支持纵向方向,ProximitySensor 将被禁用!您可以为所欲为,但如果未将人像检查为设备方向,ProximitySensor 将无法启动!

ProximitySensor is being disabled if the application doesn't support Portrait orientation! You can do whatever you want, but if Portrait is not checked as a Device Orientation, ProximitySensor wont start up!

这篇关于iOS 7、iPhone、接近传感器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆