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.
我想检查 iOS 设备当前是否连接到计算机(Wifi 和电缆)
我试图用谷歌搜索它并查看Apple Developer site,但似乎找不到与我的问题相关的任何内容。
如果设备已物理连接,您可以检查电池状态,如下所示:
UIDeviceBatteryState myBatteryState = [UIDevice currentDevice].myBatteryState; if (myBatteryState == UIDeviceBatteryStateCharging) { //code } else if (myBatteryState == UIDeviceBatteryStateFull) { //code }