【问题标题】:Reachability Go To "Wi-Fi Settings" button not working可达性转到“Wi-Fi 设置”按钮不起作用
【发布时间】:2014-03-02 16:08:28
【问题描述】:

所以我实现了可达性,因为我的应用程序使用网络服务,我的应用程序成功检测到我是否有互联网连接并警告用户...警告消息包含 2 个按钮,确定或转到 WIFI 设置

如果我按“确定”,它会解除警告并且没有任何反应,正如预期的那样......但如果我点击进入 wifi 设置,它也会解除警告,仅此而已。

下面你可以看到我的2个方法..

- (BOOL)checkForWIFIConnection {
    Reachability* wifiReach = [Reachability reachabilityForLocalWiFi];
    NetworkStatus netStatus = [wifiReach currentReachabilityStatus];
    if (netStatus!=ReachableViaWiFi)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Sem conexão à internet!", @"AlertView")
                                                            message:NSLocalizedString(@"Não está conectado à internet. Tente novamente após se connectar.", @"AlertView")
                                                           delegate:self
                                                  cancelButtonTitle:NSLocalizedString(@"Cancelar", @"AlertView")
                                                  otherButtonTitles:NSLocalizedString(@"Definições WiFi", @"AlertView"), nil];
        [alertView show];
        return NO;
    }
    else {
        return YES;
    }
}

我猜下面的代码有问题……

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1)
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
    }
}

有什么帮助吗?谢谢。

【问题讨论】:

    标签: ios objective-c uialertview reachability


    【解决方案1】:

    此 URL 架构 prefs:root=WIFI 已从 iOS 5.1 及更高版本中弃用。目前没有正式的替代品。您可能需要在您的 UIAlert on WiFi 和您的应用程序中向用户提供一些说明。

    【讨论】:

      【解决方案2】:
      ....."prefs:root=WIFI"..
      

      它不适用于 iOS 5.1。

      【讨论】:

      • 请在您的答案中添加更多细节以提高其质量。
      • 哦...那么新方法是什么?
      • 现在没办法了。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-06
      • 2016-12-30
      • 2020-03-09
      • 1970-01-01
      • 2021-08-14
      • 1970-01-01
      • 2012-01-07
      相关资源
      最近更新 更多