public interface WKUIDelegate
| Modifier and Type | Interface and Description |
|---|---|
static interface |
WKUIDelegate.Block_webViewContextMenuConfigurationForElementCompletionHandler |
static interface |
WKUIDelegate.Block_webViewRequestDeviceOrientationAndMotionPermissionForOriginInitiatedByFrameDecisionHandler |
static interface |
WKUIDelegate.Block_webViewRequestMediaCapturePermissionForOriginInitiatedByFrameTypeDecisionHandler |
static interface |
WKUIDelegate.Block_webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler |
static interface |
WKUIDelegate.Block_webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler |
static interface |
WKUIDelegate.Block_webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler |
default void webViewCommitPreviewingViewController(WKWebView webView, UIViewController previewingViewController)
webView - The web view invoking the delegate method.previewingViewController - The view controller that is being popped.default WKWebView webViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures(WKWebView webView, WKWebViewConfiguration configuration, WKNavigationAction navigationAction, WKWindowFeatures windowFeatures)
The web view returned must be created with the specified configuration. WebKit will load the request in the returned web view.
If you do not implement this method, the web view will cancel the navigation.
webView - The web view invoking the delegate method.configuration - The configuration to use when creating the new web
view. This configuration is a copy of webView.configuration.navigationAction - The navigation action causing the new web view to
be created.windowFeatures - Window features requested by the webpage.default UIViewController webViewPreviewingViewControllerForElementDefaultActions(WKWebView webView, WKPreviewElementInfo elementInfo, NSArray<?> previewActions)
Returning a view controller will result in that view controller being displayed as a peek preview. To use the defaultActions, your app is responsible for returning whichever of those actions it wants in your view controller's implementation of -previewActionItems.
Returning nil will result in WebKit's default preview behavior. webView:commitPreviewingViewController: will only be invoked if a non-nil view controller was returned.
webView - The web view invoking the delegate method.elementInfo - The elementInfo for the element the user is peeking.defaultActions - An array of the actions that WebKit would use as previewActionItems for this element by
default. These actions would be used if allowsLinkPreview is YES but these delegate methods have not been
implemented, or if this delegate method returns nil.default void webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String message, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler completionHandler)
For user security, your app should call attention to the fact that a specific website controls the content in this panel. A simple forumla for identifying the controlling website is frame.request.URL.host. The panel should have a single OK button.
If you do not implement this method, the web view will behave as if the user selected the OK button.
webView - The web view invoking the delegate method.message - The message to display.frame - Information about the frame whose JavaScript initiated this
call.completionHandler - The completion handler to call after the alert
panel has been dismissed.default void webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String message, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler completionHandler)
For user security, your app should call attention to the fact that a specific website controls the content in this panel. A simple forumla for identifying the controlling website is frame.request.URL.host. The panel should have two buttons, such as OK and Cancel.
If you do not implement this method, the web view will behave as if the user selected the Cancel button.
webView - The web view invoking the delegate method.message - The message to display.frame - Information about the frame whose JavaScript initiated this call.completionHandler - The completion handler to call after the confirm
panel has been dismissed. Pass YES if the user chose OK, NO if the user
chose Cancel.default void webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String prompt, java.lang.String defaultText, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler completionHandler)
For user security, your app should call attention to the fact that a specific website controls the content in this panel. A simple forumla for identifying the controlling website is frame.request.URL.host. The panel should have two buttons, such as OK and Cancel, and a field in which to enter text.
If you do not implement this method, the web view will behave as if the user selected the Cancel button.
webView - The web view invoking the delegate method.prompt - The prompt to display.defaultText - The initial text to display in the text entry field.frame - Information about the frame whose JavaScript initiated this call.completionHandler - The completion handler to call after the text
input panel has been dismissed. Pass the entered text if the user chose
OK, otherwise nil.default boolean webViewShouldPreviewElement(WKWebView webView, WKPreviewElementInfo elementInfo)
To disable previews entirely for the given element, return NO. Returning NO will prevent webView:previewingViewControllerForElement:defaultActions: and webView:commitPreviewingViewController: from being invoked.
This method will only be invoked for elements that have default preview in WebKit, which is limited to links. In the future, it could be invoked for additional elements.
webView - The web view invoking the delegate method.elementInfo - The elementInfo for the element the user has started touching.default void webViewDidClose(WKWebView webView)
Your app should remove the web view from the view hierarchy and update the UI as needed, such as by closing the containing browser tab or window.
webView - The web view invoking the delegate method.default void webViewContextMenuConfigurationForElementCompletionHandler(WKWebView webView, WKContextMenuElementInfo elementInfo, WKUIDelegate.Block_webViewContextMenuConfigurationForElementCompletionHandler completionHandler)
webView - The web view invoking the delegate method.elementInfo - The elementInfo for the element the user is touching.completionHandler - A completion handler to call once a it has been decided whether or not to show a context menu.
Pass a valid UIContextMenuConfiguration to show a context menu, or pass nil to not show a context menu.default void webViewContextMenuDidEndForElement(WKWebView webView, WKContextMenuElementInfo elementInfo)
webView - The web view invoking the delegate method.elementInfo - The elementInfo for the element the user is touching.default void webViewContextMenuForElementWillCommitWithAnimator(WKWebView webView, WKContextMenuElementInfo elementInfo, UIContextMenuInteractionCommitAnimating animator)
webView - The web view invoking the delegate method.elementInfo - The elementInfo for the element the user is touching.animator - The animator to use for the commit animation.default void webViewContextMenuWillPresentForElement(WKWebView webView, WKContextMenuElementInfo elementInfo)
webView - The web view invoking the delegate method.elementInfo - The elementInfo for the element the user is touching.default void webViewRequestDeviceOrientationAndMotionPermissionForOriginInitiatedByFrameDecisionHandler(WKWebView webView, WKSecurityOrigin origin, WKFrameInfo frame, WKUIDelegate.Block_webViewRequestDeviceOrientationAndMotionPermissionForOriginInitiatedByFrameDecisionHandler decisionHandler)
securityOrigin - The security origin which requested access to the device's orientation and motion.frame - The frame that initiated the request.decisionHandler - The decision handler to call once the app has made its decision.default void webViewRequestMediaCapturePermissionForOriginInitiatedByFrameTypeDecisionHandler(WKWebView webView, WKSecurityOrigin origin, WKFrameInfo frame, long type, WKUIDelegate.Block_webViewRequestMediaCapturePermissionForOriginInitiatedByFrameTypeDecisionHandler decisionHandler)
If not implemented, the result is the same as calling the decisionHandler with WKPermissionDecisionPrompt.
webView - The web view invoking the delegate method.origin - The origin of the page.frame - Information about the frame whose JavaScript initiated this call.type - The type of capture (camera, microphone).decisionHandler - The completion handler to call once the decision is made