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
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?
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.