【问题标题】:How to check which TextField is FirstResponder from another ViewController?如何从另一个 ViewController 检查哪个 TextField 是 FirstResponder?
【发布时间】:2017-09-06 16:37:36
【问题描述】:

我在 macOS 上使用 Swift 4。 我知道我可以将 becomeFirstResponder() 设置为这样的 TextField:

mytextfield.becomeFirstResponder()

但是如何检查 mytextfield 是否为 FirstResponder?

【问题讨论】:

    标签: swift macos cocoa textfield first-responder


    【解决方案1】:

    您对-becomeFirstResponder 的假设是错误的。来自文档:

    通知接收者它即将成为它的第一响应者 NSWindow。

    您可以通过NSWindow-makeFirstResponder: 做出第一反应。

    为了回答您的问题,该物业位于NSWindow,也称为firstResponder

    【讨论】:

      猜你喜欢
      • 2017-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多