如何在 Objective C 上正确写入 HTML 字符串

How to properly write an HTML string on Objective C

我想在 UIWebView 上加载网页的特定部分

 [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://jlhs.schoolloop.com/mobile/login"]]];
    [_webView loadHTMLString:@"<html><body><div class="slideshow_outer"></div></body></html>" baseURL:nil];
    [_webView setNeedsDisplay];

首先是网址 第二个是HTML我要加载的部分 第三是展示它。

我输入的 HTML 字符串出错。我该如何解决这个问题或者有更好的写法吗? 这行不通,我该如何继续?

 // show HTML content in webview there is two different types, as follow
    // 1. Using URL
    // for show web view with online url
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://jlhs.schoolloop.com/mobile/login"]]];

    // 2. Using string
    // for show web view with help of string, local page
    NSString * htmlPage = @"<html><head><meta http-equiv=\"Content-type\" content=\"text/html charset=UTF-8\" /><meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=1.5; user-scalable=0;\"/></head><body style=\"font-size:13px;font-family:Arial;-webkit-user-select:none;\">Write here your HTML content </body></html>";

    [_webView loadHTMLString:htmlPage baseURL:nil];
    // you can't use it at a time, as per your requirement use one of these.

    I hope you undersand want I want to explain.