Instance Property

allowsLinkPreview

A Boolean value that determines whether pressing on a link displays a preview of the destination for the link.

Declaration

var allowsLinkPreview: Bool { get set }

Discussion

In iOS this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is true; before that, the default value is false.

If you set this property’s value to true, an iOS user can press links to preview link destinations and detected data such as addresses and phone numbers. Such previews are known to users as peeks. If a user presses deeper on a link preview, the preview navigates (or pops, in user terminology) to the destination. Because pop navigation switches the user from your app to Safari, it is opt-in for iOS apps.

If you want to support link preview in iOS but also want to keep users within your app, you can switch from using the WKWebView class to the SFSafariViewController class. If you are using a web view as an in-app browser, making this change is best practice. The Safari view controller class automatically supports link previews.

In macOS this property is available on devices with a Force Touch trackpad. Default value is true in macOS.

With this property set to its default value of true, a macOS user can force click a link to display a preview window showing the link’s destination. If the user then clicks on the preview, the destination opens in Safari.

On both platforms, all types of detected data respond to presses when this property is set to true. That is, in iOS 9 and OS X v10.11, you cannot specify which types of data are detected in the WKWebView class.

See Also

Navigating

var allowsBackForwardNavigationGestures: Bool

A Boolean value indicating whether horizontal swipe gestures will trigger back-forward list navigations.

var backForwardList: WKBackForwardList

The web view's back-forward list.

var canGoBack: Bool

A Boolean value indicating whether there is a back item in the back-forward list that can be navigated to.

var canGoForward: Bool

A Boolean value indicating whether there is a forward item in the back-forward list that can be navigated to.

func goBack()

Navigates to the back item in the back-forward list.

func goBack(Any?)

Navigates to the back item in the back-forward list.

func goForward()

Navigates to the forward item in the back-forward list.

func goForward(Any?)

Navigates to the forward item in the back-forward list.

func go(to: WKBackForwardListItem)

Navigates to an item from the back-forward list and sets it as the current item.

func load(URLRequest)

Navigates to a requested URL.