Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ethanyuwang opened this issue Sep 17, 2018 · 0 comments
Open

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

ethanyuwang opened this issue Sep 17, 2018 · 0 comments

Comments

@ethanyuwang
Copy link

ethanyuwang commented Sep 17, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant