Package apple.webkit.protocol
Interface WKUIDelegate
-
public interface WKUIDelegateA class conforming to the WKUIDelegate protocol provides methods for presenting native UI on behalf of a webpage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceWKUIDelegate.Block_webViewContextMenuConfigurationForElementCompletionHandlerstatic interfaceWKUIDelegate.Block_webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandlerstatic interfaceWKUIDelegate.Block_webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandlerstatic interfaceWKUIDelegate.Block_webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidwebViewCommitPreviewingViewController(WKWebView webView, UIViewController previewingViewController)Allows your app to pop to the view controller it created.default voidwebViewContextMenuConfigurationForElementCompletionHandler(WKWebView webView, WKContextMenuElementInfo elementInfo, WKUIDelegate.Block_webViewContextMenuConfigurationForElementCompletionHandler completionHandler)Called when a context menu interaction begins.default voidwebViewContextMenuDidEndForElement(WKWebView webView, WKContextMenuElementInfo elementInfo)Called when the context menu ends, either by being dismissed or when a menu action is taken.default voidwebViewContextMenuForElementWillCommitWithAnimator(WKWebView webView, WKContextMenuElementInfo elementInfo, UIContextMenuInteractionCommitAnimating animator)Called when the context menu configured by the UIContextMenuConfiguration from webView:contextMenuConfigurationForElement:completionHandler: is committed.default voidwebViewContextMenuWillPresentForElement(WKWebView webView, WKContextMenuElementInfo elementInfo)Called when the context menu will be presented.default WKWebViewwebViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures(WKWebView webView, WKWebViewConfiguration configuration, WKNavigationAction navigationAction, WKWindowFeatures windowFeatures)Creates a new web view.default voidwebViewDidClose(WKWebView webView)Notifies your app that the DOM window object's close() method completed successfully.default UIViewControllerwebViewPreviewingViewControllerForElementDefaultActions(WKWebView webView, WKPreviewElementInfo elementInfo, NSArray<?> previewActions)Allows your app to provide a custom view controller to show when the given element is peeked.default voidwebViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String message, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler completionHandler)Displays a JavaScript alert panel.default voidwebViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String message, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler completionHandler)Displays a JavaScript confirm panel.default voidwebViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String prompt, java.lang.String defaultText, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler completionHandler)Displays a JavaScript text input panel.default booleanwebViewShouldPreviewElement(WKWebView webView, WKPreviewElementInfo elementInfo)Allows your app to determine whether or not the given element should show a preview.
-
-
-
Method Detail
-
webViewCommitPreviewingViewController
default void webViewCommitPreviewingViewController(WKWebView webView, UIViewController previewingViewController)
Allows your app to pop to the view controller it created.- Parameters:
webView- The web view invoking the delegate method.previewingViewController- The view controller that is being popped.
-
webViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures
default WKWebView webViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures(WKWebView webView, WKWebViewConfiguration configuration, WKNavigationAction navigationAction, WKWindowFeatures windowFeatures)
Creates a new web view. 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.- Parameters:
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.- Returns:
- A new web view or nil.
-
webViewPreviewingViewControllerForElementDefaultActions
default UIViewController webViewPreviewingViewControllerForElementDefaultActions(WKWebView webView, WKPreviewElementInfo elementInfo, NSArray<?> previewActions)
Allows your app to provide a custom view controller to show when the given element is peeked. 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.- Parameters:
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.
-
webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler
default void webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String message, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler completionHandler)
Displays a JavaScript alert panel. 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.- Parameters:
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.
-
webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler
default void webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String message, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler completionHandler)
Displays a JavaScript confirm panel. 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.- Parameters:
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.
-
webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler
default void webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler(WKWebView webView, java.lang.String prompt, java.lang.String defaultText, WKFrameInfo frame, WKUIDelegate.Block_webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler completionHandler)
Displays a JavaScript text input panel. 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.- Parameters:
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.
-
webViewShouldPreviewElement
default boolean webViewShouldPreviewElement(WKWebView webView, WKPreviewElementInfo elementInfo)
Allows your app to determine whether or not the given element should show a preview. 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.- Parameters:
webView- The web view invoking the delegate method.elementInfo- The elementInfo for the element the user has started touching.
-
webViewDidClose
default void webViewDidClose(WKWebView webView)
Notifies your app that the DOM window object's close() method completed successfully. 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.- Parameters:
webView- The web view invoking the delegate method.
-
webViewContextMenuConfigurationForElementCompletionHandler
default void webViewContextMenuConfigurationForElementCompletionHandler(WKWebView webView, WKContextMenuElementInfo elementInfo, WKUIDelegate.Block_webViewContextMenuConfigurationForElementCompletionHandler completionHandler)
Called when a context menu interaction begins.- Parameters:
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.
-
webViewContextMenuDidEndForElement
default void webViewContextMenuDidEndForElement(WKWebView webView, WKContextMenuElementInfo elementInfo)
Called when the context menu ends, either by being dismissed or when a menu action is taken.- Parameters:
webView- The web view invoking the delegate method.elementInfo- The elementInfo for the element the user is touching.
-
webViewContextMenuForElementWillCommitWithAnimator
default void webViewContextMenuForElementWillCommitWithAnimator(WKWebView webView, WKContextMenuElementInfo elementInfo, UIContextMenuInteractionCommitAnimating animator)
Called when the context menu configured by the UIContextMenuConfiguration from webView:contextMenuConfigurationForElement:completionHandler: is committed. That is, when the user has selected the view provided in the UIContextMenuContentPreviewProvider.- Parameters:
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.
-
webViewContextMenuWillPresentForElement
default void webViewContextMenuWillPresentForElement(WKWebView webView, WKContextMenuElementInfo elementInfo)
Called when the context menu will be presented.- Parameters:
webView- The web view invoking the delegate method.elementInfo- The elementInfo for the element the user is touching.
-
-