我得到电池状态和其他。
UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
float batLeft = [myDevice batteryLevel];
int i=[myDevice batteryState];
int batinfo=(batLeft*100);
NSLog(@"Battry Level is :%d and Battery Status is :%d",batinfo,i);
switch (i)
{
case UIDeviceBatteryStateUnplugged:
{
break;
}
case UIDeviceBatteryStateCharging:
{
break;
}
case UIDeviceBatteryStateFull:
{
break;
}
default:
{
break;
}
}现在我试着得到温度的细节,它有可能从设备获得电池温度。
发布于 2022-11-17 09:40:07
如果您不需要温度编号,那么使用ThermalState api是有用的。
https://developer.apple.com/documentation/foundation/nsprocessinfothermalstate?language=objc
https://stackoverflow.com/questions/38823260
复制相似问题