iOS:是否可以以编程方式读取手机电池百分比?

标签 ios battery

是否可以通过 iOS 应用程序以编程方式读取手机电池百分比

最佳答案

您可以使用以下代码。

if (![[UIDevice currentDevice] isBatteryMonitoringEnabled])
 {
   [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
 }
 NSLog(@"battery : %f", [[UIDevice currentDevice] batteryLevel]);

关于iOS:是否可以以编程方式读取手机电池百分比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38785842/

相关文章:

ios - UITableView 在 iPhone 和 iPad 上有不同的选择行为

ios - 重新创建谷歌收件箱的 ios 加号按钮

java - 在 Android 中获取电池电量和状态

android - 经常观察电池?

ios - 通过iOS应用程序控制低电量模式

ios - 正确使用 DrawRect 覆盖 - 我可以防止 View 拉伸(stretch)吗?

c# - Xamarin : UISearchController is not becoming first responder and editing is not getting started while adding it to Navigation Bar

ios - 在 iOS 中计算电池生命周期

iphone - 在 UITabBarController 或 UINavigationController 中生成 'hole'?

android - 使用 EXTRA_PLUGGED 获取 USB 电缆插入 IN/OUT 事件不起作用