Home:ALL Converter>Disable only picture selection in WKWebView

Disable only picture selection in WKWebView

Ask Time:2020-09-24T15:06:07         Author:coder

Json Formatter

I am working on an epub reader, and currently moving from UIWebView to WKWebView.

I noticed that WKWebView allows user to select a picture, save it, share it or copy it. I want to disable user from selecting a picture, but keep text selection available.

I do control the MenuItem of text Selection using the following:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
    if (action == @selector(copy:) || action == @selector(select:) || action == @selector(selectAll:) || action == @selector(share:) || action == @selector(lookUp:)) {
        return NO;
    }
    else if (action == @selector(defineAction:) || action == @selector(highlightColor:) || action == @selector(Copying:)) {
        return YES;
    }
    else {
        return NO;
    }
}

I was wondering if I can control or totally disable the MenuItem of picture selection

Kindly find below a screenshot where upon trying to select the text, sometimes the image gets selected instead and it allows the user to save the picture, which would lead to data infringement.

enter image description here

If any further code is needed kindly keep me posted.

Author:coder,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/64041163/disable-only-picture-selection-in-wkwebview
yy