我正在使用此功能获取设备的当前电池电量:
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
double batLeft = (float)[myDevice batteryLevel];
NSLog(@"%f",batLeft);
Run Code Online (Sandbox Code Playgroud)
但结果的粒度为5%.示例:当手机电池电量为88%时,它仅记录0.85的值.batteryLevel仅以0.05为增量返回值.例如:0.85,0.9,0.95并且永远不会返回0.82或0.83之类的值.
是否有任何解决方案可以获得更高精度的百分比?