WKUIDelegate protocol is for you.
First, make your view controller conform to it by adding
WKUIDelegate to its list of protocols. Second, assign your view controller to the
uiDelegate property of your web view:
yourWebView.uiDelegate = self
Finally, implement whichever of the optional methods of
WKUIDelegate takes your interest. For example, you can make
WKWebView show a custom alert controller when any web page uses the
Available from iOS 10.0
Did this solution work for you? Please pass it on!
Other people are reading…
About the Swift Knowledge Base
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Help support Hacking with Swift
This site is funded by Hacking with Swift supporters who buy my e-books. If you can, please support my work – it comes packed with bonus material!