Conforms to NSObject
Declared in WKUIDelegate.h

Overview

A class conforming to the WKUIDelegate protocol provides methods for presenting native UI on behalf of a webpage.

Instance Methods

webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:

- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
Discussion

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.

navigationAction

The navigation action causing the new web view to be created.

windowFeatures

Window features requested by the webpage.

Return Value

A new web view or nil.

Declared In

WKUIDelegate.h

webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:

- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void ( ^ ) ( ))completionHandler
Discussion

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.

Declared In

WKUIDelegate.h

webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:

- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void ( ^ ) ( BOOL result ))completionHandler
Discussion

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.

Declared In

WKUIDelegate.h

webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:

- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void ( ^ ) ( NSString *result ))completionHandler
Discussion

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.

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.

message

The message to display.

Declared In

WKUIDelegate.h