ozd
ozd

Reputation: 1284

Disable 3D touch for iOS application

I have an application that present webViews.

This WebViews present links that I want to handle by myself.

Everything is working great using the delegate methods, but I have a problem when the user is using force touch. In that case, the iOS is making the transition to the link via safari without going listening to my delegate.

My question is - How can I remove the force touch from my app?

Thanks

Upvotes: 2

Views: 4558

Answers (3)

demosten
demosten

Reputation: 3381

According this WebKit post, allowsLinkPreview is false by default on iOS 9 and enabled by default on iOS 10+

WebKit supports Peek and Pop as an easy way to preview links. Apps built against the iOS 10 SDK will have Peek and Pop link preview enabled by default, but the feature is not new; since iOS 9, WKWebView clients could opt into Peek-based link previews on 3D Touch-capable devices using the allowsLinkPreview property on WKWebView. When the allowsLinkPreview property is set to true, users can gently press on links to peek them, which loads the link in another view over the app and blurs the app in the background.

try setting it to false

Upvotes: 8

ozd
ozd

Reputation: 1284

The way to remove 3d touch from your web view is -

yourWebView.allowsLinkPreview = false

Upvotes: 13

torinpitchers
torinpitchers

Reputation: 1292

i believe this is what your looking for:

func webView(_ webView: WKWebView, shouldPreviewElement elementInfo: WKPreviewElementInfo) -> Bool {
    return false
}

its a delegate method in WKUIDelegate which was added in iOS10. This will disable the force touch preview.

Upvotes: 0

Related Questions