3

With the iOS 15 update, in my web application is appear a new functionality that I want to disable. This feature is based on a long press and dragging is possible to select some text.

Feature example gif

Feature example gif

i've tried to use:

WKWebViewConfiguration* conf = [[WKWebViewConfiguration alloc] init];
WKPreferences *preferences = [[WKPreferences alloc] init];
preferences.textInteractionEnabled = false;
conf.preferences = preferences;

but it disable all interactions with text, text inputs too.

Someone can help me, please?

m4n0
  • 29,823
  • 27
  • 76
  • 89
ALD
  • 33
  • 1
  • 6

1 Answers1

0

Maybe just using CSS will solve your problem (write code below in your own html or css file):

user-select: none;
-webkit-user-select: none;

If you are not familiar with CSS,here is a sample code that inject CSS with JS in your Objective-C Code:

[webView evaluateJavaScript:@"function addStyle(){const style=document.createElement('style');style.textContent='user-select: none;-webkit-user-select: none;';document.head.append(style)};addStyle();" completionHandler:NULL];

Ref:

user-select - MDN

Inject CSS stylesheet as string using Javascript

Panway
  • 46
  • 4