2011-05-03 126 views
0

我正在嘗試顯示網頁 http://johnbridge180.com/Boarders.html 我無法完全解決這個問題我只有一個錯誤:''webView'未聲明。下面是應用程序的代碼: WebViewController.h:錯誤:'webView'未聲明

// 
    // WebViewController.h 
    // Boarders 
    // 
    // Created by John Bridge on 5/2/11. 
    // Copyright 2011 Bridge and co. All rights reserved. 
    // 

    #import <UIKit/UIKit.h> 
    @interface WebViewController : UIViewController { 

IBOutlet UIWebView *displayWeb; 
    } 
    @end 

WebViewcontroller.m:

// 
    // WebViewController.m 
    // Boarders 
    // 
    // Created by John Bridge on 5/2/11. 
    // Copyright 2011 Bridge and co. All rights reserved. 
    // 

    #import "WebViewController.h" 


    @implementation WebViewController 
    - (void)viewDidLoad { 
     displayWeb.userInteractionEnabled = true; 
     [displayWeb loadRequest:[[NSURLRequest alloc] initWithURL:[[NSURL alloc]   initWithString:@"http://www.johnbridge180.com/Boarders.html"]]]; 
[super viewDidLoad]; 
    } 
    @end 

希望你們能幫忙,謝謝!

+2

顯示錯誤的是哪一行?什麼是確切的錯誤信息? – Anna 2011-05-03 01:54:30

回答

0

你在這裏介紹的代碼很好。但是,從錯誤我假設你正在試圖調用「webView」名稱的'displayWeb'變量。搜索認爲你的.m文件'webView',你會發現它。

也嘗試乾淨你的項目,如果這不起作用。

您的代碼也泄漏(很多)。請查看cocoa memory management basics

0

這裏有幾個問題...

您沒有正確創建您的網址和要求,他們不會被正確清理你在做它的方式。

- (void)viewDidLoad { 
     displayWeb.userInteractionEnabled = true; 
     [displayWeb loadRequest:[NSURLRequest requestWithUrl:[NSURL urlWithString:@"http://www.johnbridge180.com/Boarders.html"]]]; 
     [super viewDidLoad]; 
    } 

這樣你就可以創建一個自動發佈的網址和請求。

請提供一些信息,它說webView沒有聲明。

+0

同樣的錯誤,但這次更多的警告 – 2011-05-03 19:21:02