<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 -> 이런 이슈가 나온다
'ios,swift' 카테고리의 다른 글
[ios] swift NSMutableAttributedString color 부분변경방법 (0) | 2020.01.31 |
---|---|
[ios] swift linker command failed with exit code 1 해결방법 (0) | 2020.01.30 |
[ios] swift String trim방법 (0) | 2020.01.30 |
[ios] swift click animation 사라지게 하기 (0) | 2020.01.30 |
[ios] swift String으로 Data타입 만들어서 JsonDecoder하는 방법 (0) | 2020.01.30 |