I’m trying to load a UIWebView, but I can’t understand why doesn’t work, I’m doing this:
Loading *load = [[Loading alloc] init];
[load searchName];
then Loading.h
@interface Loading : NSObject <UIWebViewDelegate>
{
UIWebView *myWebView;
}
- (void) searchName;
Loading.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);
}
why never call webViewDidFinishLoad method?
The reason your webview is not displayed is you have taken
NSObjectclass andNSObjectclasses dont have anXIBand the way you have done is just calling your-(void)searchNamemethod and is not adding it toself.view.