iPhone接近传感器

编程入门 行业动态 更新时间:2024-10-08 18:35:18
本文介绍了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接近传感器

本文发布于:2023-11-24 00:56:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623382.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:传感器   iPhone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!