5

I was just wondering whether iPhone developement allows light sensors to be used, as buttons or action elements??

I found this link online...

Possible to use Light Sensor as a Button? [Archive] - Touch Arcade

If anyone could shed some light on the issue, I'd appreciate the help?

Cheers.

Divanshu.

chollida
  • 7,664
  • 11
  • 52
  • 85
Divanshu
  • 51
  • 1
  • 3

3 Answers3

3

An official answer by an Apple rep is on the Apple Dev Forums (login required):

There's no supported way to get at the ambient light sensor. If you'd like to see such support added in the future, I encourage you to file a bug describing your requirements. While we may have seen similar requests many times before, a fresh bug report will allow you to express your needs in your own terms, and allow iOS engineering to gauge the level of demand. http://developer.apple.com/bugreporter

samvermette
  • 40,051
  • 27
  • 111
  • 143
1

Check out this article. There's some code you can download at the bottom. Also, a related question on SO where I found the link.

Community
  • 1
  • 1
Cᴏʀʏ
  • 101,556
  • 20
  • 162
  • 188
-1

In the 3.0 SDK the UIDevice class has the proximityState and proximityMonitoringEnabled properties.

BOOL buttonPressed = [UIDevice currentDevice].proximityState;

... gives you the current state.

Keep in mind that the iPod Touch does not have a proximity sensor.

Nikolai Ruhe
  • 80,564
  • 16
  • 176
  • 197
  • 3
    The proximity sensor isn't the light sensor – SeniorShizzle Jul 13 '10 at 09:14
  • The ambient light sensor is NOT the same as the proximity sensor (says the person who's only feedback option is a comment as I'm not hip enough to down-vote a candidate answer) – Minok Nov 12 '13 at 22:27