ios,swift2020. 1. 30. 18:37

<html>

    

    <body>

        

        <script>

            

            alert("Hello, world!");

            

            </script>

        

    </body>

    

</html>

 

 

WKUIDelegate -> delegate 등록 시켜주고

 

@IBOutlet weak var webKitView: WKWebView!

 

override func viewDidLoad() {

 

        super.viewDidLoad()

 

webKitView.uiDelegate = self

}

 

 

 // java alert

    func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {

        print("message ->\(message)")

        self.showToast(message: message)

        completionHandler()

    }

 

completionHandler() 꼭 해야 한다... 않하면 

 

runJavaScriptAlertPanelWithMessage:initiatedByFrame was not called -> 이런 이슈가 나온다

Posted by thdeodls85