How to insert HTML into a UIWebView
36,894
Solution 1
This should do the trick:
NSString *myHTML = @"<html><body><h1>Hello, world!</h1></body></html>";
[myUIWebView loadHTMLString:myHTML baseURL:nil];
Solution 2
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;
baseURL can be a fileURL to your resources folder if you have any images.
Author by
Mohan Gulati
Updated on July 18, 2020Comments
-
Mohan Gulati almost 4 years
I have HTML Content which was being displayed in a
UITextView
. The next iteration of my app is display the HTML contents into aUIWebView
. So, I basically replaced myUITextView
withUIWebView
. However I could not figure out how to insert my HTML snippet into the view. It seems to need aURLRequest
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?