<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKUIDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKUIDelegate"
  },
  "title" : "WKUIDelegate"
}
-->

# WKUIDelegate

The methods for presenting native user interface elements on behalf of a webpage.

```
@MainActor protocol WKUIDelegate : NSObjectProtocol
```

## Overview

Web view user interface delegates implement this protocol to control the opening of new windows, augment the behavior of default menu items displayed when the user clicks elements, and perform other user interface-related tasks. These methods can be invoked as a result of handling JavaScript or other plug-in content. The default web view implementation assumes one window per web view, so nonconventional user interfaces might implement a user interface delegate.

## Topics

### Creating and closing the web view

[`webView(_:createWebViewWith:for:windowFeatures:)`](/documentation/WebKit/WKUIDelegate/webView(_:createWebViewWith:for:windowFeatures:))

Creates a new web view.

[`webViewDidClose(_:)`](/documentation/WebKit/WKUIDelegate/webViewDidClose(_:))

Notifies your app that the DOM window closed successfully.

### Displaying UI panels

[`webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:))

Displays a JavaScript alert panel.

[`webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:))

Displays a JavaScript confirm panel.

[`webView(_:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:))

Displays a JavaScript text input panel.

[`webView(_:showLockdownModeFirstUseMessage:completionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:showLockdownModeFirstUseMessage:completionHandler:))

Displays a custom Lockdown Mode first use message.

[`WKDialogResult`](/documentation/WebKit/WKDialogResult)

An enumeration that lists the possible ways a delegate handled displaying a custom Lockdown Mode first use dialog.

### Displaying an upload panel

[`webView(_:runOpenPanelWith:initiatedByFrame:completionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:runOpenPanelWith:initiatedByFrame:completionHandler:))

Displays a file upload panel.

[`WKOpenPanelParameters`](/documentation/WebKit/WKOpenPanelParameters)

The configuration details of a file upload control in your web content.

### Displaying a contextual menu

  <doc://com.apple.documentation/documentation/UIKit/adding-context-menus-in-your-app>

[`webView(_:contextMenuConfigurationForElement:completionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:contextMenuConfigurationForElement:completionHandler:))

Tells the delegate that a contextual menu interaction began.

[`webView(_:contextMenuForElement:willCommitWithAnimator:)`](/documentation/WebKit/WKUIDelegate/webView(_:contextMenuForElement:willCommitWithAnimator:))

Provides the delegate with the animator object that the web view uses to display the contextual menu.

[`webView(_:contextMenuWillPresentForElement:)`](/documentation/WebKit/WKUIDelegate/webView(_:contextMenuWillPresentForElement:))

Tells the delegate that the web view is about to present the contextual menu for the specified element.

[`webView(_:contextMenuDidEndForElement:)`](/documentation/WebKit/WKUIDelegate/webView(_:contextMenuDidEndForElement:))

Tells the delegate that the web view dismissed the contextual menu for the specified element.

  <doc://com.apple.documentation/documentation/UIKit/UIContextMenuConfiguration>

### Displaying an edit menu

[`webView(_:willDismissEditMenuWithAnimator:)`](/documentation/WebKit/WKUIDelegate/webView(_:willDismissEditMenuWithAnimator:))

Tells the delegate that the web view is about to dismiss an edit menu.

[`webView(_:willPresentEditMenuWithAnimator:)`](/documentation/WebKit/WKUIDelegate/webView(_:willPresentEditMenuWithAnimator:))

Tells the delegate that the web view is about to present an edit menu.

### Requesting permissions

[`webView(_:requestDeviceOrientationAndMotionPermissionFor:initiatedByFrame:decisionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:requestDeviceOrientationAndMotionPermissionFor:initiatedByFrame:decisionHandler:))

Determines whether a web resource, which the security origin object describes, can access the device’s orientation and motion.

[`webView(_:requestMediaCapturePermissionFor:initiatedByFrame:type:decisionHandler:)`](/documentation/WebKit/WKUIDelegate/webView(_:requestMediaCapturePermissionFor:initiatedByFrame:type:decisionHandler:))

Determines whether a web resource, which the security origin object describes, can access to the device’s microphone audio and camera video.

[`WKPermissionDecision`](/documentation/WebKit/WKPermissionDecision)

An enumeration of possible permission decisions for device resource access.

[`WKMediaCaptureType`](/documentation/WebKit/WKMediaCaptureType)

An enumeration listing the types of media devices that can capture audio, video, or both.

### Deprecated

[Deprecated symbols](/documentation/WebKit/wkuidelegate-deprecated-symbols)

Review unsupported symbols and their replacements.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)