如何在网络连接禁用时显示警报?
问题描述:
我是新来iPhone在我的应用程序我通过网络服务连接到数据库它工作正常,但我想在网络连接disable.please任何帮助我如何警告时,网络连接禁用,以提醒警告 感谢提前。如何在网络连接禁用时显示警报?
答
当你被你代表/观察员网络禁用状态通知,你可以在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知道网络连接的状态。
重复http://*.com/questions/4954904/reachability-vs-uidevice-reachability和http://*.com/questions/1861656/iphone-reachability-checking – 2011-05-17 07:15:59