gpt4 book ai didi

ios - 覆盖 iOS 上的 "Look Up"菜单项

转载 作者:行者123 更新时间:2023-12-01 21:58:21 25 4
gpt4 key购买 nike

当您在 iOS 中选择文本时,其中一个菜单项称为“查找”。

是否可以覆盖此行为并显示您自己的 View Controller ?

enter image description here

最佳答案

您可以覆盖这些命令并通过 UIMenuController 和 UIMenuItem 类提供自定义控件:

  • https://developer.apple.com/documentation/uikit/uimenucontroller
  • https://nshipster.com/uimenucontroller/

    UIMenuItem

    With iOS 3.2, developers could now add their own commands to the menu controller. As yet unmentioned, but familiar commands like “Define” or spell check suggestions take advantage of this.

    UIMenuController has a menuItems property, which is an NSArray of UIMenuItem objects. Each UIMenuItem object has a title and action. In order to have a menu item command display in a menu controller, the responder must implement the corresponding selector.

  • 关于ios - 覆盖 iOS 上的 "Look Up"菜单项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60857165/

    25 4 0