更新时间:2023-01-01 18:32:20
试试这个示例代码 示例 和
https://github.com/tonymillion/Reachability
Try with this sample code Sample and
https://github.com/tonymillion/Reachability
它还可以让您检查是否启用了 WiFi:
It will also allow you to check if WiFi is enabled:
Reachability* reachability = [Reachability sharedReachability];
[reachability setHostName:@"www.google.com"]; // set your host name here
NetworkStatus remoteHostStatus = [reachability remoteHostStatus];
if(remoteHostStatus == NotReachable) { }
else if (remoteHostStatus == ReachableViaWiFiNetwork) { }
else if (remoteHostStatus == ReachableViaCarrierDataNetwork) { }