I am facing problem, when i am trying to load this type of html
string
(<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)
in webview
.
problem is raised due to backward slaces.
Any Help will Appreciated
URL string has a problem with forward slash(es) /
in your html string.
Correct url string is: https://dams-apps-production.s3.ap-south-1.amazonaws.com/course_file_meta/73857742.PNG
Here I tried this and its working:
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)
}
}
Result:
If the back-slashes are your problem, you should remove them:
let origString = ...
let unescapedString = origString.replacingOccurrences(of: "\\", with: "")
webview.loadHTMLString(unescapedString, baseURL:nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With