user4150758
user4150758

Reputation: 453

How to use a display nsstring content in uiwebview?

I have an nsstring which basically contains Html and JavaScript code in the string. How can I use the string so that I can display that content in the uiwebview. Actually I'm planning to display google charts.

Note: I don't want to use a separate html file. I want to use nsstring because I get the some values from objective c code and then I'm planning to display on the uiwebview. I appreciate any kind of help. Thank you.

Upvotes: 0

Views: 1338

Answers (1)

Gad
Gad

Reputation: 2877

If your NSString is indeed an HTML string you should be able to load it into a UIWebView like so:

// Create and add a webview
UIWebView * myWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
[self.view addSubview:myWebView];

// Load the webview with HTML
NSString * myHTMLString = @"<HTML><BODY>Some HTML Code</BODY></HTML>";
[myWebView loadHTMLString:myHTMLString baseURL:nil];

Upvotes: 1

Related Questions