A collection of properties used to initialize a web view.


class WKWebViewConfiguration : NSObject


Using the WKWebViewConfiguration class, you can determine how soon a webpage is rendered, how media playback is handled, the granularity of items that the user can select, and many other options.

WKWebViewConfiguration is only used when a web view is first initialized. You cannot use this class to change the web view's configuration after it has been created.


Configuring the New Web View’s Properties

var applicationNameForUserAgent: String?

The name of the application as used in the user agent string.

var preferences: WKPreferences

The preference object to be used by the web view.

var processPool: WKProcessPool

The process pool from which to obtain the view’s Web Content process.

var userContentController: WKUserContentController

The user content controller to associate with the web view.

var websiteDataStore: WKWebsiteDataStore

The website data store to be used by the web view.

Determining Webpage Scalability

var ignoresViewportScaleLimits: Bool

A Boolean value that determines whether a WKWebView object should always allow scaling of the webpage.

Setting Rendering Preferences

var suppressesIncrementalRendering: Bool

A Boolean value indicating whether the web view suppresses content rendering until it is fully loaded into memory.

Setting Media Playback Preferences

var allowsInlineMediaPlayback: Bool

A Boolean value indicating whether HTML5 videos play inline or use the native full-screen controller.

var allowsAirPlayForMediaPlayback: Bool

A Boolean value indicating whether AirPlay is allowed.

var allowsPictureInPictureMediaPlayback: Bool

A Boolean value indicating whether HTML5 videos can play picture-in-picture.

var mediaTypesRequiringUserActionForPlayback: WKAudiovisualMediaTypes

Determines which media types require a user gesture to begin playing.

var mediaPlaybackAllowsAirPlay: Bool

Deprecated property. Instead, use allowsAirPlayForMediaPlayback.

var requiresUserActionForMediaPlayback: Bool

A Boolean value indicating whether HTML5 videos require the user to start playing them (true) or whether the videos can be played automatically (false).

struct WKAudiovisualMediaTypes

The media types that require a user gesture to begin playing

Setting Selection Granularity

var selectionGranularity: WKSelectionGranularity

The level of granularity with which the user can interactively select content in the web view.

enum WKSelectionGranularity

The granularity with which a selection can be created and modified interactively.

Selecting User Interface Directionality

var userInterfaceDirectionPolicy: WKUserInterfaceDirectionPolicy

The directionality of user interface elements.

enum WKUserInterfaceDirectionPolicy

The policy used to determine the directionality of user interface elements in a web view.

Identifying Data Types

var dataDetectorTypes: WKDataDetectorTypes

The type of data detection desired.

struct WKDataDetectorTypes

The type of data detected.

Adding Handlers for New URL Schemes

func setURLSchemeHandler(WKURLSchemeHandler?, forURLScheme: String)

Adds a URL scheme handler object for a given URL scheme.

func urlSchemeHandler(forURLScheme: String) -> WKURLSchemeHandler?

Returns the currently registered scheme handler for the given URL scheme


Inherits From

See Also


protocol WKNavigationDelegate

The methods of the WKNavigationDelegate protocol help you implement custom behaviors that are triggered during a web view's process of accepting, loading, and completing a navigation request.

class WKProcessPool

A WKProcessPool object represents a pool of Web Content processes.

class WKWindowFeatures

A WKWindowFeatures object specifies optional attributes for the containing window when a new web view is requested.

class WKWebView

An object that displays interactive web content, such as for an in-app browser.

class WKPreferences

A WKPreferences object encapsulates the preference settings for a web view.

protocol WKUIDelegate

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

Viewing Desktop or Mobile Web Content Using a Web View

Implement a simple iPad web browser that can view either the desktop or mobile version of a website.