iPhone应用程序的Internet连接不可用消息 [英] Internet connection unavailable message for iPhone app

查看:196
本文介绍了iPhone应用程序的Internet连接不可用消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要在首次启动时从服务器加载其数据,我想添加一条消息,以便在互联网连接未激活的情况下提醒用户,因为它现在已经完成,当没有连接时崩溃。谢谢。

I have an application that needs to load its data from the server when it first launch, i want to add a message that alert user in case the internet connection is not active as it is done right now it crashes when there's no connection. Thank you.

推荐答案

如果它与失败的互联网连接有关,你可以使用NSURLConnectionDataDelegate方法之一:

If its related to failing internet connection you can use one of the NSURLConnectionDataDelegate methods:

-(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]);
}

这篇关于iPhone应用程序的Internet连接不可用消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆