How to insert HTML into a UIWebView

后端 未结 3 1247
既然无缘
既然无缘 2021-01-30 07:19

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

相关标签:
3条回答
  • 2021-01-30 07:43

    This example shows how we can se HTML into UIWebView and

    func someFunction() {
    
        uiWebView.loadHTMLString("<html><body></body></html>", baseURL: nil)
        uiWebView.delegate = self as? UIWebViewDelegate
    }
    
    func webViewDidFinishLoad(_ webView: UIWebView) {
        //ready to be processed
    }
    

    Do not forget to extend a class from UIWebViewDelegate and nil the delegate

    0 讨论(0)
  • 2021-01-30 07:50

    This should do the trick:

    NSString *myHTML = @"<html><body><h1>Hello, world!</h1></body></html>";
    [myUIWebView loadHTMLString:myHTML baseURL:nil];
    
    0 讨论(0)
  • 2021-01-30 08:01
    - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;
    

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

    0 讨论(0)
提交回复
热议问题