iPhone接近传感器 [英] iPhone Proximity Sensor

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

问题描述

能否在iPhone SDK利用iPhone的接近传感器?如果是这样,为什么没有采取利用它们的人?我可以想象几个像样的用途。

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.

例如,在赛车游戏中,你可以把在接近传感器你的手指去占用了屏幕房地产用拇指来代替。当然,虽然,如果这是你唯一的选择,那么iPod touch用户将无法使用该应用程序。

For example, in a racing game, you could put your finger on the proximity sensor to go instead of taking up screen real-estate with your thumb. Of course though, if this was your only option, then iPod touch users wouldn't be able to use the application.

是否接近传感器告诉你是多么接近,或者只是的东西是在它前面的?

Does the proximity sensor tell how close you are, or just that something is in front of it?

推荐答案

假设你的意思是关闭当你把它抱到你的耳朵屏幕上的传感器,我是pretty肯定,这只是内部的红外传感器听筒。如果启动手机应用程序(不必进行拨打电话),并持有一些过耳扬声器蒙上了一层阴影,可以使显示器关闭。

Assuming you mean the sensor that shuts off the screen when you hold it to your ear, I'm pretty sure that is just an infrared sensor inside the ear speaker. If you start the phone app (you don't have to be making a call) and hold something to cast a shadow over the ear speaker, you can make the display shut off.

当你问这个问题,它不是通过公共API访问。您现在可以通过的UIDevice的 proximityState 属性访问传感器的状态。然而,这将不会对游戏是有用的,因为它是唯一的一个开/关的事情,而不是远/近量度。此外,它仅适用于iPhone和不是iPod touch上。

When you asked this question it was not accessible via the public API. You can now access the sensor's state via UIDevice's proximityState property. However, it wouldn't be that useful for games, since it is only an on/off thing, not a near/far measure. Plus, it's only available on the iPhone and not the iPod touch.

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

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