본문 바로가기

iOS - Swift

[swift] wkwebview decidePolicyFor not called

반응형
SMALL

webview에서 화면 이동시 원인은 모르겠으나 decidePolicyFor 에 url 체크가 안될때가 있음

 

>>>>>

 

//페이지 이동 체크

webview.addObserver(self, forKeyPath: "URL", options: .new, context: nil)

 

추가 후

 

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {

        if keyPath == #keyPath(WKWebView.url) {

            guard let url_ = self.webview.url?.absoluteString else {

                return

            }

            

           //.. 동작 ..

        }

    }

 

해결!

반응형
LIST