我正在将本地 HTML 加载到 UIWebView 中,如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
//Setup our UIWebView
webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
webView.delegate = self;
webView.scalesPageToFit = YES;
webView.userInteractionEnabled = YES;
[self.view addSubview:webView];
...
[self loadWebPage];
}
- (void)loadWebPage {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
}
在标题中:
@interface ViewController : UIViewController <UIWebViewDelegate>
但是由于某种原因,我的 webview 代表没有被调用:
- (void)webViewDidStartLoad:(UIWebView *)webView {
NSLog(@"Starting HTML Load Process");
}
- (void)webViewDidFinishLoad:(UIWebView *)webViewRef {
NSLog(@"Web View Finished Loading Method");
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
NSLog(@"Error loading HTML ! %@", error);
}
谁能建议为什么?
谢谢 !