gpt4 book ai didi

iphone - 如何检查wifi选项是否启用

转载 作者:技术小花猫 更新时间:2023-10-29 11:00:55 26 4
gpt4 key购买 nike

如何检查 iPhone 上是否启用了 wifi 选项(但可能 iPhone 未连接到其中一个 wifi 网络)。

最佳答案

为此,您需要在项目中导入可达性类。

之后:-

#import "Reachability.h"

在你查看 DidLoad 时写:-

- (void)viewDidLoad {
Reachability *internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifer];
Reachability *wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
[wifiReach startNotifer];

NetworkStatus netStatus1 = [internetReach currentReachabilityStatus];
NetworkStatus netStatus2 = [wifiReach currentReachabilityStatus];
if(netStatus1 == NotReachable && netStatus2 == NotReachable)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"This feature requires an internet connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
else
{//wifi connection available;
}
}

关于iphone - 如何检查wifi选项是否启用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7975727/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com