UIWebView无法加载URL?

时间:2012-05-02 12:19:39

标签: iphone objective-c ios uiwebview uiwebviewdelegate

我在我的应用中添加了UIWebView,以便允许用户浏览互联网网站,但即使我对网址进行硬编码,UIWebView也始终显示为空白。

请允许任何人告诉我代码中的错误:

- (void)viewWillAppear:(BOOL)animated {  
    [super viewWillAppear:animated];

    if(!webView)
    {
        self.webView = [[UIWebView alloc]init];
    }

    webView.delegate = self;

    NSString *urlAddress = @"http://www.google.com";
    //Create a URL object.
    NSURL *url = [NSURL URLWithString:urlAddress];
    //URL Requst Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    //Load the request in the UIWebView.
    [webView loadRequest:requestObj];   
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"Started");
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSLog(@"Stopped");
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSLog(@"Error");
}

0 个答案:

没有答案