首页 文章

可达性类“NotReachable”仅检查WIFI连接

提问于
浏览
0

我实际上坚持使用Apple的Reachability类问题 .

我正在检查互联网连接:

Reachability *r = [Reachability reachabilityWithHostName:@"http://google.com"];
    NetworkStatus internetStatus = [r currentReachabilityStatus];

    if (internetStatus == NotReachable){

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Keine Internetverbindung" message:@"Diese Applikation erfordert eine Internetverbindung. Bitte aktivieren Sie diese um die Inhalte korrekt darstellen zu können." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    else {
        // The stuff if want to do with connection
    }

我在模拟器和我的iPhone 4上测试过 . 它运行正常,但仅适用于WIFI . 如果我不在WIFI网络中,我仍会收到警告消息 . 谁能告诉我为什么它不检查iPhone的3G或移动数据网络连接?

1 回答

相关问题