2010-12-02 80 views

回答

4
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; 

if ([[UIDevice currentDevice] batteryState] != UIDeviceBatteryStateUnplugged) { 
    //Device is connected (charging or fully charged) 
} 

编辑:如果你relly要检查设备是否充电(而不是100%满还),使用UIDeviceBatteryStateCharging不断if语句。有关更多信息,请参阅the documentation