我是使用加载html字符串方法将html文件加载到webview。一切正常。在我的代码中,用户选择图像作为配置文件,然后选择修复路径和名称上的图像保存。当用户选择图像时,当Web视图重新加载时,图像显示旧图像。映像已更新到目录,但不显示。 此问题仅发生在Ipad中,在Iphone中工作正常。
有什么建议吗? 那么请建议
我的加载代码
webview.loadHTMLString(invoiceHTML, baseURL: NSURL(string:resumeComposer.HTMLFilePath)! as URL)
图像源更新为 HTML 字符串代码
imgPath = URL(fileURLWithPath: folderpathforNormal).appendingPathComponent("ProfileImg.png").path
HTMLContent = HTMLContent?.replacingOccurrences(of: "*userimage*", with: imgPath)
首先清除UIWebview缓存,如下所示:
//to remove cache from UIWebview
URLCache.shared.removeAllCachedResponses()
if let cookies = HTTPCookieStorage.shared.cookies {
for cookie in cookies {
HTTPCookieStorage.shared.deleteCookie(cookie)
}
}