我正在使用加载 html 字符串方法将 Html 文件加载到 webview。一切正常。在我的代码中,用户选择图像作为配置文件并选择图像保存在修复路径和名称上。当用户选择图像时,当 web View 重新加载时,图像显示旧图像。图像更新到目录但不显示。 此问题仅在 Ipad 中出现,在 Iphone 中正常。
有什么建议。?那么请推荐
//我的加载代码
webview.loadHTMLString(invoiceHTML, baseURL: NSURL(string:resumeComposer.HTMLFilePath)! as URL)
//Image Source更新为HTML String代码
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)
}
}
关于ios - Webview 不刷新图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45615412/