我在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
答案 0 :(得分:1)
在 .h 文件
中写下此行@property (nonatomic,retain) IBOutlet UIWebView *WebView1;
在 .m 文件
中写下此行@synthesize WebView1;