【问题标题】:Internet connection unavailable message for iPhone appiPhone 应用程序的 Internet 连接不可用消息
【发布时间】:2011-11-15 09:10:47
【问题描述】:

我有一个应用程序需要在首次启动时从服务器加载其数据,我想添加一条消息提醒用户以防互联网连接不活动,因为它现在完成了它在没有连接时崩溃.谢谢。

【问题讨论】:

    标签: iphone ios


    【解决方案1】:

    如果它与失败的互联网连接有关,您可以使用 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]);
    }
    

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多