- (BOOL)canPerformAction:(SEL)ac
2016-09-21 本文已影响3269人
公爵海恩庭斯
重写此方法,来控制 UIMenuItem 的显示和隐藏:
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:))
{
return YES;
}
else if (action == @selector(select:))
{
return YES;
}
else if (action == @selector(selectAll:))
{
return YES;
}
return [super canPerformAction:action withSender:sender];
}
以下是系统默认的 UIMenuItem 所对应的 action:
-
cut:
// 剪切 -
copy:
// 拷贝 -
select:
// 选择 -
selectAll:
// 全选 -
paste:
// 粘贴 -
delete:
// 删除 -
_promptForReplace:
// Replace... -
_transliterateChinese:
// 简<=>繁 -
_showTextStyleOptions:
// B/<u>U</u> -
_define:
// Define -
_addShortcut:
// Learn... -
_accessibilitySpeak:
// Speak -
_accessibilitySpeakLanguageSelection:
// Speak... -
_accessibilityPauseSpeaking:
// Pause -
_share:
// 共享... -
makeTextWritingDirectionRightToLeft:
// 往右缩进 -
makeTextWritingDirectionLeftToRight:
// 往左缩进