2010-12-02 103 views

回答

4
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; 

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

編輯:如果你relly要檢查設備是否充電(而不是100%滿還),使用UIDeviceBatteryStateCharging不斷if語句。有關更多信息,請參閱the documentation