Perseus
Perseus

Reputation: 1588

UIWebView not loading the XHTML file properly

I have a sample.xhtml file which has few lines of javascript. This javascript will load a pdf file from the net.

If I use simple .xhtml file, it is loading properly. If I use Javascript, the webView is not displaying the .xhtml file properly

[_webView loadData:htmlData MIMEType:@"application/xhtml+xml" textEncodingName:@"UTF-8" baseURL:url];

Upvotes: 0

Views: 747

Answers (2)

Rinju  Jain
Rinju Jain

Reputation: 1694

try this. to load your file path

- (void)viewDidLoad {  
  filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"xhtml"]; 
  NSURL* url = [NSURL fileURLWithPath:filePath]; 
  [self.myWebView loadRequest:[NSURLRequest requestWithURL:url]];
}

Upvotes: 0

Rinju  Jain
Rinju Jain

Reputation: 1694

- (void)viewDidLoad {   

 //NSString *strHTML;  (.h)
 [self.myWebView loadHTMLString:strHTML baseURL:nil];
 }

//delegate

 - (void)webViewDidFinishLoad:(UIWebView *)webView {
[myWebView stringByEvaluatingJavaScriptFromString:strHTML];
}

Upvotes: 1

Related Questions