【问题标题】:Detect paste event in UITextField? [duplicate]检测 UITextField 中的粘贴事件? [复制]
【发布时间】:2020-12-11 22:45:51
【问题描述】:

如何检测用户是否将某些内容粘贴到 UITextField?

我在网上和 StackOverflow 上找到的所有答案都与 UITextViews 相关。

【问题讨论】:

  • 这个answer 是针对 UITextField 的,即使问题是关于 UITextView。

标签: ios swift swift4 swift5


【解决方案1】:

您只需要在您的 UITextField 委托上覆盖 UIResponderStandardEditActions 粘贴方法:

override func paste(_ sender: Any?) {
    print("do someting")
    super.paste(sender)
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    相关资源
    最近更新 更多