Skip to content

How to use a UIWebView with added category instead? #274

Open
@ethanyuwang

Description

@ethanyuwang

I need to disable copy and cut and have found this post: https://stackoverflow.com/a/11290826/8710951

I have created a category file as instructed:

UIWebView+DisableCopy.h

#import <UIKit/UIKit.h>

@interface UIWebView (DisableCopy)
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender;
@end

UIWebView+DisableCopy.m

#import "UIWebView+DisableCopy.h"

@implementation UIWebView (DisableCopy)

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    BOOL superCanPerform = [super canPerformAction:action withSender:sender];
    if (superCanPerform) {
        if (action == @selector(copy:) ||
            action == @selector(cut:))
        {
            return NO;
        }
    }
    return superCanPerform;
}

@end

Then I imported this file in RCTWebViewBridge.m: #import "UIWebView+DisableCopy.h"

However, the above approach has taken no effect. I have zero knowledge about objective C. What would be the correct way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions