質問

How to disable popup menu items like Select, Select All, Suggest..., Define (on UIWebView)?

I have found the following information on the help but don't understand how to use it:

For the editing menu commands, this is the shared UIApplication object. Depending on the context, you can query the sender for information to help you determine whether a command should be enabled.

役に立ちましたか?

解決

Swizzle the following method:

#import "NSObject+myCanPerformAction.h"

@implementation NSObject (myCanPerformAction)

- (BOOL)myCanPerformAction:(SEL)action withSender:(id)sender {
    if (action == @selector(copy:)) {
        return [self myCanPerformAction:action withSender:sender]; // not a recursion
    }
    if (action == @selector(paste:)) {
        return [self myCanPerformAction:action withSender:sender]; // not a recursion
    }
    return NO;
}

@end

Swizzling:

[[UIWebDocumentView class] jr_swizzleMethod:@selector(canPerformAction:withSender:) withMethod:@selector(myCanPerformAction:withSender:) error:nil];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top