-
What's new in WKWebView
Explore the latest updates to WKWebView, our framework for incorporating web content into your app's interface. We'll show you how to use the JavaScript fullscreen API, explore CSS viewport units, and learn more about find interactions. We'll also take you through refinements to content blocking controls, embedding encrypted media, and using the Web Inspector.
Recursos
Vídeos relacionados
WWDC22
-
Buscar neste vídeo...
-
-
2:26 - Fullscreen API support
webView.configuration.preferences.isElementFullscreenEnabled = true webView.loadHTMLString(""" <script> button.addEventListener('click', () => { canvas.webkitRequestFullscreen() }, false); </script> … """, baseURL:nil) let observation = webView.observe(\.fullscreenState, options: [.new]) { object, change in print("fullscreenState: \(object.fullscreenState)") } -
3:50 - CSS viewport unit range inputs
let minimum = UIEdgeInsets(top: 0, left: 0, bottom: 30, right: 0) let maximum = UIEdgeInsets(top: 0, left: 0, bottom: 200, right: 0) webView.setMinimumViewportInset(minimum, maximumViewportInset: maximum) -
4:17 - Using UIFindInteraction with WKWebView
webView.findInteractionEnabled = true if let interaction = webView.findInteraction { interaction.presentFindNavigator(showingReplace:false) } -
5:46 - WKContentRuleList if-frame-url
let json = """ [{ "action":{"type":"block"}, "trigger":{ "resource-type":["image"], "url-filter":".*", "if-frame-url":["https?://([^/]*\\\\.)wikipedia.org/"] } }] """ WKContentRuleListStore.default().compileContentRuleList(forIdentifier: "example_blocker", encodedContentRuleList: json) { list, error in guard let list = list else { return } let configuration = WKWebViewConfiguration() configuration.userContentController.add(list) }
-