我想显示的提示信息时,用户没有互联网连接我用下面的代码,但它从来没有进入到这一块它永远不会触发它从来没有所谓iOS版 - 连接失败的提示信息时,在我的应用程序没有互联网连接
如何控制用户是否有网络连接?
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"connect");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Failed" message:@"check your internet connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
注:我使用的iOS 5.1版本,我已经把我的代表们到.h文件
确保这个方法是在你的NSURLConnection的 – Vatev 2012-07-22 14:44:39
的代表,我有代表:NSURLConnectionDataDelegate,NSURLConnectionDelegate – ercan 2012-07-22 14:49:25
https://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference .html它在NSURLConnectionDelegate中。 – hkulekci 2012-07-22 14:49:37