-2

我在 viewcontroller.m 中有这个错误“使用未声明的标识符'webview'”。我还需要从文件“www”中调用 html 页面。

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    NSString *localFilePath = [[NSBundle mainBundle] pathForResource:@"www/index" ofType:@"html"] ;
    NSURLRequest *localRequest = [NSURLRequest requestWithURL:
                              [NSURL fileURLWithPath:localFilePath]] ;

    [webView loadRequest:localRequest] ;

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface ViewController : UIViewController

@property (assign) IBOutlet UIWebView *WebView1;

@end
4

1 回答 1

1

在你的.h文件中写下这一行

@property (nonatomic,retain) IBOutlet UIWebView *WebView1;

在你的.m文件中写下这一行

@synthesize WebView1;
于 2013-07-09T13:39:33.850 回答