[英]Internet connection unavailable message for iPhone app
我有一個應用程序,它需要在服務器首次啟動時從服務器加載其數據,我想添加一條消息,以警告用戶萬一Internet連接處於活動狀態,因為它已經完成,當沒有連接時會崩潰。 謝謝。
如果其與失敗的Internet連接有關,則可以使用NSURLConnectionDataDelegate方法之一:
-(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]);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.