Reading the iPhone's Ambient Light sensor
Try using GSEventSetBacklightLevel();
, which requires <GraphicsServices/GraphicsServices.h>
. This is how one can programmatically adjust the brightness levels. There is also a get
option, so I think that may have the information you're after.
iPhone Proximity Sensor
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.
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.
Related Topics
Alternative iOS Layouts for Portrait and Landscape Using Just One .Xib File
iOS 5.1 with Xcode 4.2 and Retina in iPad 3
Programmatically Add Centerx/Centery Constraints
How to Switch to Different Storyboard for iPhone 5
Single Function to Dismiss All Open View Controllers
Change Language of Alert in Banner of Push Notification
Kvo and Arc How to Removeobserver
Xcode 10: Unable to Attach Db Error
Why am I Getting Ibtool Failed with Exit Code 255
Swift - How to Hide Back Button in Navigation Item
How Does Cellforrowatindexpath Work
Enterprise In-House App Distribution
Swift Performselector:Withobject:Afterdelay: Is Unavailable
When How to Activate/Deactivate Layout Constraints
Why Push Notifications Is Not Working on Testflight
How to Create a User with Multiple Attributes in Firebase with Swift