WKWebView function for detecting if the URL has changed

前端 未结 3 963
孤城傲影
孤城傲影 2020-12-03 11:19

Is there a function for the WKWebView class that allows you to detect whenever the URL of that WebView has changed?

The didCommit and didStartProv

3条回答
  •  醉话见心
    2020-12-03 11:42

    You may add an observer:

    [webView_ addObserver:self forKeyPath:@"URL" options:NSKeyValueObservingOptionNew context:NULL];

    and the corresponding method that gets called when the URL changes:

    -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

提交回复
热议问题