2011-05-17 103 views
0

我是新來iPhone在我的應用程序我通過網絡服務連接到數據庫它工作正常,但我想在網絡連接disable.please任何幫助我如何警告時,網絡連接禁用,以提醒警告 感謝提前。如何在網絡連接禁用時顯示警報?

+0

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

回答

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]; 

您還可以使用API​​的Reachability知道網絡連接的狀態。

iPhone SDK: Testing Network Reachability

1

看一看這個S.O. entry

尤其是對你的興趣點主要是第一位的,有關使用可達性框架來檢測網絡的連通性。