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

风流意气都作罢 提交于 2019-12-31 03:59:34

问题


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.


回答1:


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];


来源:https://stackoverflow.com/questions/13233613/how-to-disable-popup-menu-items-like-select-select-all-suggest-define-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!