Sensor summary
Sensor type |
Role |
Ambient light sensor |
Sensing ambient light intensity (automatically adjusts screen brightness) |
Distance sensor |
Sensing if there are other objects near the device screen (call Auto lock screen) |
Magnetometer sensor |
Sensing the surrounding magnetic field (co-Gai) |
Internal temperature sensor |
Sensing the temperature inside the device (reminding the user to cool down, preventing damage to the device) |
Humidity sensor |
Whether the induction equipment is flooded (to facilitate maintenance personnel) |
Gyroscope |
Holding mode of induction equipment (racing games) |
Acceleration meter |
Motion of induction equipment (shaking, pedometer) |
Open Range Sensing function
2 [Uidevice currentdevice].proximitymonitoringenabled = YES;
3//Listen to the notification of distance sensing
4 [[Nsnotificationcenter Defaultcenter] Addobserver:self
5 selector: @selector (proximitychange:)
6 name:uideviceproximitystatedidchangenotification
7 Object:nil];
8
9-(void) Proximitychange: (Nsnotificationcenter *) Notification {
if ([uidevice currentdevice].proximitystate = = YES) {
One NSLog (@ "An object is close to the device screen"); The screen will automatically lock
() Else {
NSLog (@ "An object is away from the device screen"); The screen will automatically unlock
14}
15}
IOS Sensor Learning