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

查看:39
本文介绍了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?

推荐答案

假设您指的是当您将屏幕靠近耳朵时关闭屏幕的传感器,我很确定这只是耳机内部的红外传感器.如果您启动电话应用程序(您不必拨打电话)并按住某物在耳机上投下阴影,您可以关闭显示屏.

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天全站免登陆