当我尝试加载这种类型的html字符串时,我遇到了问题
(<p>Identify the arrow-marked structures in the images<img alt=\"\" src=\"https:\/\/dams-apps-production.s3.ap-south-1.amazonaws.com\/course_file_meta\/73857742.PNG\" \/><\/p>\r\n)
Run Code Online (Sandbox Code Playgroud)
在webview。问题是由于向后倾斜而引发的。
任何帮助都会受到赞赏
URL 字符串/在您的 html 字符串中存在正斜杠问题。
正确的 url 字符串是:https : //dams-apps-production.s3.ap-south-1.amazonaws.com/course_file_meta/73857742.PNG
在这里,我尝试了这个及其工作:
class WebKitController: UIViewController {
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
loadHTMLStringImage()
}
func loadHTMLStringImage() -> Void {
let htmlString = "<p>Identify the arrow-marked structures in the images<img alt=\"\" src=\"https://dams-apps-production.s3.ap-south-1.amazonaws.com/course_file_meta/73857742.PNG\"></p>"
webView.loadHTMLString(htmlString, baseURL: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
如果反斜杠是您的问题,您应该将其删除:
let origString = ...
let unescapedString = origString.replacingOccurrences(of: "\\", with: "")
webview.loadHTMLString(unescapedString, baseURL:nil)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11123 次 |
| 最近记录: |