views:

246

answers:

2

I have HTML Content which was being displayed in a UITextView. The next iteration of my app is display the HTML contents into a UIWebView. So I basically replaced my UITextView with UIWebView. However I could not figure out how to inset my HTML snippit into the view. It seems to need a URLRequest which I do not want. I have already stored the HTML content in memory and want to load and display it from memory.

Any ideas how I should proceed?

+1  A: 
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;

baseURL can be a fileURL to your resources folder if you have any images.

drawnonward
...or just `nil` if your HTML doesn't reference external files.
jlehr
Thank you as well :)
Mohan Gulati
+1  A: 

This should do the trick:

NSString *myHTML = @"<html><body><h1>Hello, world!</h1></body></html>";
[myUIWebView loadHTMLString:myHTML baseURL:nil];
igul222