如何在网络连接禁用时显示警报?

问题描述:

我是新来iPhone在我的应用程序我通过网络服务连接到数据库它工作正常,但我想在网络连接disable.please任何帮助我如何警告时,网络连接禁用,以提醒警告 感谢提前。如何在网络连接禁用时显示警报?

+0

重复http://*.com/questions/4954904/reachability-vs-uidevice-reachability和http://*.com/questions/1861656/iphone-reachability-checking – 2011-05-17 07:15:59

使用UIAlertView显示警报

当你被你代表/观察员网络禁用状态通知,你可以在UIAlertView显示消息。

//show an alert to let the user know that they can't connect... 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Status" message:@"Network is not available. Please try again later." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
     [alert show]; 
     [alert release]; 

您还可以使用API​​的Reachability知道网络连接的状态。

iPhone SDK: Testing Network Reachability

看一看这个S.O. entry

尤其是对你的兴趣点主要是第一位的,有关使用可达性框架来检测网络的连通性。