如何删除选定文本的“搜索网页”选项iOS 16 xcode14测试版

kcwpcxri  于 2023-01-14  发布在  iOS
关注(0)|答案(2)|浏览(221)

当文本被选中时,我无法删除此勾选符号,我尝试了以下方法:

class CustomUITextField: UITextField {
   open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
      return false
   }
}

删除了复制、粘贴等功能,但似乎没有删除iOS 16的新功能。感谢您的帮助:)

8mmmxcuj

8mmmxcuj1#

您可以尝试:

- (void)buildMenuWithBuilder:(id<UIMenuBuilder>)builder API_AVAILABLE(ios(13.0))  {
        if (@available(iOS 16.0, *)) {
            [builder removeMenuForIdentifier:UIMenuLookup];
        }
        [super buildMenuWithBuilder:builder];
    }
zbq4xfa0

zbq4xfa02#

将以下代码添加到自定义子类中:

@available(iOS 13.0, *)
override func buildMenu(with builder: UIMenuBuilder) {
    builder.remove(menu: .lookup)

    super.buildMenu(with: builder)
}

相关问题