WKWebView reLoad()无法刷新当前页面 [英] WKWebView reload() can't refresh current page
本文介绍了WKWebView reLoad()无法刷新当前页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
第一次加载网页时脱机失败。
然后连接网络调用reload()
刷新当前页面,但不工作,WKNavigationDelegate
无法回调。
函数reloadFromOrigin()
也不起作用
但医生说:
/*! @abstract Reloads the current page.
@result A new navigation representing the reload.
*/
- (nullable WKNavigation *)reload;
/*! @abstract Reloads the current page, performing end-to-end revalidation
using cache-validating conditionals if possible.
@result A new navigation representing the reload.
*/
- (nullable WKNavigation *)reloadFromOrigin;
谁能帮帮🍭
推荐答案
第一次加载网页脱机失败。则webview.url为nil
。尝试以下代码:
func reloadButtonDidTap() {
if webview.url != nil {
webview.reload()
} else {
webview.load(URLRequest(url: originalURL))
}
}
这篇关于WKWebView reLoad()无法刷新当前页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文