我想从代码中获取电池使用数据。 我怎么能这样做?
答案 0 :(得分:0)
代码如下所示
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
float batteryLevel = [[UIDevice currentDevice] batteryLevel];
//This will give you the battery between 0.0 (empty) and 1.0 (100% charged)
//If you want it as a percentage, you can do this:
batteryLevel *= 100;