UIMenuItem 上该段的名称是什么?
我知道 UIMenuController
可以显示包含剪切、复制、粘贴、选择/的弹出窗口所有和其他系统菜单项。但我不知道最后一项是什么,如上面的屏幕截图所示。它的作用是什么?它是否调用应用程序内的任何内容?如果是,是什么?可以禁用吗?在这种情况下,我想以编程方式禁用或删除该项目,而不禁用任何国际键盘。
I know that the UIMenuController
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您正在谈论以编程方式禁用 RTL 菜单项而不禁用国际键盘,那么您似乎无法做到这一点 - 至少在使用
UIMenuController 时不能。
如果您查看其文档menuItems
属性,它解释了可以在系统项目之后插入自定义项目,但没有表明您可以删除由于某种原因不需要的那些系统项目。点击它可能会导致 iOS 调用
UITextInput
协议的setBaseWritingDirection:forRange:
方法。不过,我对此一无所知——我只能猜测,因为在短暂浏览文档后我没有意识到对此有明确的解释。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 itsmenuItems
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'ssetBaseWritingDirection: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.图中最右边的“箭头”
UIMenuItem
确实是一个系统项。它的选择器称为_setRtoLTextDirection
: 或_setLtoRTextDirection
: 我怀疑苹果不希望你搞乱它们,因为当你尝试输入这些方法。要禁用它们,请检查它们并在覆盖的 -
(BOOL)canPerformAction:(SEL)action withSender:(id)sender
方法中返回“NO”。对于想要禁用
UIMenuItemController
中默认UIMenuItems
的任何人,您可以在我的 博客。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 theUIMenuItemController
, you can find the complete list (or most of them at least) in my blog.