我试过这样做:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
return NO;
}
但它仍然弹出菜单,我也想保留副本,我只想删除“定义”,这可能吗?为了澄清我不想删除文本选择的能力,我只想删除UIMenuController中的“define”选项
答案 0 :(得分:0)
你是否可以在canPerformAction中返回YES:withSender在响应链中进一步向上?
请注意,如果您的类为命令返回NO,则响应者链上的另一个响应者可能仍然返回YES,从而启用该命令。
答案 1 :(得分:-1)
您需要继承UIWebView,然后
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
// XLOG(@"perform action %@ with sender %@.", NSStringFromSelector(action), sender);
if ((action == @selector(cut:)) || (action == @selector(copy:)) || (action == @selector(select:)) ||
(action == @selector(selectAll:)) || (action == @selector(paste:)) || (action == @selector(delete:)))
return [super canPerformAction:action withSender:sender];
return NO;
}