I know that the UIMenuContro开发者_如何学Pythonller
can show a popover containing Cut, Copy, Paste, Select/All, and other system menu items. But I don't know what the last item is, visible in the screenshot above. What is its function? Does it call anything within the application, and if so, what? Can it be disabled? In this case, I would like to disable or remove the item programmatically, without disabling any international keyboards.
Assuming you are talking about disabling the RTL menu item programmatically without disabling international keyboards, it doesn't appear that you can - at least not while using UIMenuController.
If you look at the documentation for its menuItems
property, it explains that custom items can be inserted after system items, but makes no indication that you can remove those system items that you for some reason do not want.
Tapping it might result in iOS calling the UITextInput
protocol's setBaseWritingDirection:forRange:
method. I don't know about that, though – I can only guess since there's no clear explanation of this that I'm aware of after a short run around the documentation.
That right-most "arrow" UIMenuItem
pictured is indeed a system item. The selector for it is called _setRtoLTextDirection
: or _setLtoRTextDirection
: I suspect apple wouldn't want you messing with them as the auto-complete in Xcode doesn't help you when you try to type these methods.
To disable them, check for them and return "NO" in your overridden - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
method.
For anyone else that wants to disable the default UIMenuItems
in the UIMenuItemController
, you can find the complete list (or most of them at least) in my blog.
精彩评论