【发布时间】:2021-04-04 07:06:22
【问题描述】:
如何仅对 uitextfield 中的文本选择禁用“查找”和“共享”。以下是我尝试过的快速代码
override public func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if action == #selector(copy(_:)) || action == #selector(paste(_:)) || action == #selector(delete(_:)) || action == #selector(cut(_:))
{
return true
} else if action == Selector(("_lookup:")) || action == Selector(("_share:")) || action == Selector(("_define:")) {
return false
}
return super.canPerformAction(action, withSender: sender)
}
我只想显示剪切、复制、粘贴和删除,无论是否选择文本。
【问题讨论】:
标签: ios swift uitextfield