A Boolean value that determines whether pressing on a link displays a preview of the destination for the link.
SDKs
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
Framework
- Web
Kit
Declaration
@property(nonatomic) BOOL allowsLinkPreview;
Discussion
In iOS this property is available on devices that support 3D Touch. In iOS 10 and later, the default value is YES
; before that, the default value is NO
.
If you set this property’s value to YES
, 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 WKWeb
class to the SFSafari
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 YES
in macOS.
With this property set to its default value of YES
, 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 YES
. That is, in iOS 9 and OS X v10.11, you cannot specify which types of data are detected in the WKWeb
class.