1

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];
}

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I come from the PHP world and I'm patiently waiting for the moment when Objective-C snaps and everything makes sense.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.