2012-02-20 49 views
0

我有一个代码来检测,如果我有互联网连接或没有,有时它不工作。下面的代码:我的代码,以检查我是否有互联网连接不好

-(void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error 
{ 
    UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"Error" message:@"Couldn't connect to the Internet. Please check your connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    [alert show]; 
    [alert release]; 
} 

的问题是,有时网络不加载其他的东西,而不是因为它有一个不好的连接。我希望有更好的方法来检查WiFi。任何想法?

+0

Internet conniption,呃? – 2012-02-20 20:00:02

+6

可能重复的[如何检查iPhone SDK上的活动Internet连接?](http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone -sdk) – 2012-02-20 20:00:25

+0

你可以检查WiFi连接,甚至主机可达性 - 检查链接乔希给你 – 2012-02-20 20:02:38

回答