Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人知道如何使用 Swift 读取使用闪电端口连接到 iPhone 的设备的电池百分比吗?如果有人知道这是不可能的,我也会非常感激。如果确实不可能,我应该使用蓝牙吗?
非常感谢所有的帮助者...
对此没有“标准化”方式 - 如果您的配件通过其专有协议支持此功能,则可以 - 否则您无法获得此功能
如果有的话,它将通过:
https://developer.apple.com/library/prerelease/ios/documentation/ExternalAccessory/Reference/ExternalAccessoryFrameworkReference/index.html
如果设备支持电池电量UIDeviceBatteryState,那么这可能UIDeviceBatteryStateDidChangeNotification是另一个不错的起点。
UIDeviceBatteryState
UIDeviceBatteryStateDidChangeNotification