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

时间:2011-05-17 07:13:10

标签: iphone

我在我的应用程序中对iphone是新手我通过正常工作的Web服务连接到数据库,但我想在网络连接被禁用时取消警告。请帮助我如何在禁用网络连接时发出警报,   提前谢谢。

3 个答案:

答案 0 :(得分:1)

看看这个S.O. entry

特别是,您的主要兴趣点是关于使用Reachability框架检测网络连接的第一个问题。

答案 1 :(得分:0)

使用UIAlertView显示提醒

答案 2 :(得分:0)

当您的代理人/观察员收到有关网络禁用状态的通知时,您可以在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];

您还可以使用Reachability API来了解网络连接的状态。

iPhone SDK: Testing Network Reachability