【问题标题】:iOS - how to detect if power is connected to the iDevice ad is chargingiOS - 如何检测电源是否连接到 iDevice 广告正在充电
【发布时间】:2012-07-02 13:19:30
【问题描述】:

我正在尝试确定他的设备是否已插入并正在充电。如何在 ios 5.x 或更高版本中找到?

【问题讨论】:

标签: ios apple-push-notifications power-management


【解决方案1】:

您可以使用UIDevice 获取这些信息

使用下面的

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];

if ([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateCharging)
    NSLog(@"device is conected to power");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多