WKWebView reload()无法刷新当前页面

abo*_*jan 5 ios swift wkwebview

第一次加载网页在离线时失败.然后我连接网络调用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;
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗

Kos*_*awa 11

第一次加载网页在离线时失败.然后是webview.url nil.请尝试以下代码:

func reloadButtonDidTap() {
    if let url = webview.url {
        webview.reload()
    } else {
        webview.load(URLRequest(url: originalURL))
    }
}
Run Code Online (Sandbox Code Playgroud)