【问题标题】:UIAlertView from Tab Button - No Internet Connection来自选项卡按钮的 UIAlertView - 没有 Internet 连接
【发布时间】:2012-06-04 10:55:22
【问题描述】:

再次寻求帮助...

我的应用程序目前有 2 个部分需要互联网连接,1 个是通过 Flickr 的照片库,另一个是 Twitter Feed,我想知道这是否是 UIAlertView 的正确代码...我可以得到它通过一个按钮工作,但仅此而已!

{
-(void)didTap_roundedRectButton1:(id)sender forEvent:(UIEvent *)event {
UIAlertView *alertView = [[UIAlertView alloc] init];
alertView.title = @"You are not connected to the Internet!";
alertView.message = @"Please check your connection and try again...";
[alertView addButtonWithTitle:@"Ok"];
[alertView show];
[alertView release];
} 

【问题讨论】:

  • 另外请记住,如果您的应用在连接中断时尝试访问网络资源,例如设备处于飞行模式,iOS 会向您发出警报。在这些情况下,您可能不需要额外提醒用户。

标签: iphone objective-c xcode cocoa xcode4.3


【解决方案1】:

我认为您需要使用此示例,因为我已经使用它来检查是否有可用的网络以及设备是否连接到任何一个网络,它在苹果的开发者示例站点上也可用 示例链接是this

【讨论】:

【解决方案2】:

你应该试试这个:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"You are not connected to the Internet!" 
                                                  message:@"Please check your connection and try again..."
                                                 delegate:nil 
                                        cancelButtonTitle:@"OK" 
                                        otherButtonTitles: nil];

  [alertView show];
  [alertView release];

你能贴出你如何创建 UIButton 的代码吗?

【讨论】:

  • 对不起,我认为我的问题是错误的!我几乎完成了我的应用程序,但遗漏了 Apple 在提交时要求的“无 Internet 连接”错误,如果我在没有互联网的情况下单击我的应用程序中的“照片库”,它会使应用程序崩溃,不知道为什么?我以为我需要一个 UIAlertView 来检查连接?任何帮助都会很棒的家伙......
猜你喜欢
  • 1970-01-01
  • 2016-10-16
  • 2011-11-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-02
  • 1970-01-01
  • 2012-01-31
相关资源
最近更新 更多