我已经搜索过,但没有找到像我这样的问题。我确定这是我看过的东西。
我正在使用 tony Million 的可达性块方法。当我有互联网然后没有互联网时,它运行良好。警报出现并且工作正常。
但是,当我没有互联网然后我上网时,会弹出相同的警报
我的代码是
-(void)reachabilityBlock
{
// allocate a reachability object
Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"];
// tell the reachability that we DONT want to be reachable on 3G/EDGE/CDMA
reach.reachableOnWWAN = YES;
reach.reachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"REACHABLE! block");
[self newsTableViewRefresher];
});
};
reach.unreachableBlock = ^(Reachability * reachability)
{
dispatch_async(dispatch_get_main_queue(), ^{
//NSLog(@"UNREACHABLE! block");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"No Network found!"
message: @"You have no wifi or cellular connection available. Please connect to a WIFI or cellular network."
delegate: self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
});
};
[reach startNotifier];
[self.refreshControl endRefreshing];
}
我的问题是为什么当我上网时会弹出无法访问的警报?
感谢您的时间