【发布时间】:2014-06-15 18:32:03
【问题描述】:
我正在 xCode 中制作一个带有简单 web 视图的应用程序。如果没有可用的互联网连接,我希望通知用户。当没有互联网连接时,会弹出一个窗口告诉您“没有可用的互联网连接”和两个选项 - 重试,然后取消。我该怎么做呢?我是这方面的初学者,所以请简单解释一下。
ViewController.m
#import "ViewController.h"
@interface ViewController () <UIWebViewDelegate>
@end
@implementation ViewController
@synthesize webView;
- (void)viewDidLoad
{
NSURL *url = [NSURL URLWithString:@"http://MyWebPage.com"];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
webView.delegate = self;
[webView loadRequest:requestURL];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
【问题讨论】:
-
呃,你具体做了哪些研究? SO 不是您的“为我编写代码”网站。这很简单,但你应该自己学习。
-
通过让你解释我如何做到这一点,我将能够学习..
-
这不是教学网站。从 Apple 文档中学习,如果您遇到问题,请在此处通过显示您尝试过的内容和无效的内容来提问。