2011-05-03 117 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