我正在尝试加载一个UIWebView
,但我不明白为什么不起作用,我正在这样做:
Loading *load = [[Loading alloc] init];
[load searchName];
然后加载.h
@interface Loading : NSObject <UIWebViewDelegate>
{
UIWebView *myWebView;
}
- (void) searchName;
加载.m
- (void) searchName{
myWebView = [[UIWebView alloc] init];
myWebView.delegate = self;
NSString *urlAddress = @"www.google.com";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[myWebView loadRequest:requestObj];
}
- (void)webViewDidFinishLoad:(UIWebView *)thisWebView
{
NSString *yourHTMLSourceCodeString = [myWebView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"];
NSLog(@"%@",yourHTMLSourceCodeString);
}
为什么从不调用webViewDidFinishLoad
方法?