我在viewcontroller.m中有這個錯誤「使用未聲明的標識符'webview'」。我也需要從文件「www」調用html頁面。錯誤使用未聲明的標識符webview
#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
您嘗試訪問命名實例變量'webView'。但是,您只有一個名爲'WebView1'的屬性。這將無法正常工作,請閱讀您的錯誤消息,而不要依賴Stackoverflow Driven Development。你也應該拋棄iOS 4,並在你的屬性中使用弱而不是分配。 –