the first time load web page fail at offline.
then I connect network call reload()
to refresh current page, but it is not work, the WKNavigationDelegate
can't get any callback.
the function reloadFromOrigin()
also not work
but the doc says:
/*! @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;
Can someone help 🍭
The WKWebView already contains a scrollview. All you need to do is create the refresh control, assign a target function that will get called when a user initiates a refresh, and attach the refresh control to the scrollview.
You can implement WKWebView in Objective-C, here is simple example to initiate a WKWebView : WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init]; WKWebView *webView = [[WKWebView alloc] initWithFrame:self. view. frame configuration:theConfiguration]; webView.
The first time load web page fail at offline. Then webview.url be nil
. Try the following code:
func reloadButtonDidTap() {
if webview.url != nil {
webview.reload()
} else {
webview.load(URLRequest(url: originalURL))
}
}
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