Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone应用程序的Internet连接不可用消息_Iphone_Ios - Fatal编程技术网

iPhone应用程序的Internet连接不可用消息

iPhone应用程序的Internet连接不可用消息,iphone,ios,Iphone,Ios,我有一个应用程序,当它第一次启动时需要从服务器加载数据,我想添加一条消息,提醒用户如果internet连接没有激活,就像现在这样,当没有连接时它会崩溃。谢谢。使用可达性类检查网络连接 如果与internet连接失败有关,您可以使用NSURLConnectionDataDelegate方法之一: -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { UIAlertView*aview

我有一个应用程序,当它第一次启动时需要从服务器加载数据,我想添加一条消息,提醒用户如果internet连接没有激活,就像现在这样,当没有连接时它会崩溃。谢谢。

使用可达性类检查网络连接

如果与internet连接失败有关,您可以使用NSURLConnectionDataDelegate方法之一:

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{

UIAlertView*aview=[[UIAlertView alloc]initWithTitle:@"Connection Failed" message:@"Please check your internet connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil ];
[aview show];
[aview release]; // Notify the user about the failure.

NSLog(@"Reason:%@",[error description]);
}