Reputation: 169
How would I modify the following to accept an HTML string rather than load a file? I need to create HTML on the fly and pass it to the UIWebView.
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"emergency" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
Upvotes: 1
Views: 3796
Reputation: 5831
I think it helps you....just paste in button action
UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(20, 50, 320, 460)];
[wv loadHTMLString:@"<html><body><a href='http://iosstoryboard.blogspot.in'>Click Me</a></body></html>" baseURL:nil];
[self.view addSubview:wv];//wait for some seconds to load.
Upvotes: 1
Reputation: 1302
This should do the trick:
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
That is a method on UIWebView. See the class reference for more info.
Upvotes: 3