【问题标题】:How do I forward an action message to the next responder?如何将操作消息转发给下一个响应者?
【发布时间】:2014-09-30 13:55:46
【问题描述】:

如果我有类似的东西:

void maybeHandleMessage: sender: AnyObject {
    if isHandling() {
        handle()
    } else {
        // forward action message to next responder in the responder chain
    }
}

else 子句中需要什么代码来转发maybeHandleMessage?

【问题讨论】:

  • [self.nextResponder doSomething:param];

标签: ios cocoa-touch uiresponder


【解决方案1】:

如果您的对象是UIResponder 的一种子类,则有一个方法

func nextResponder() -> UIResponder?

你可以试试

【讨论】:

  • 这可以在 cocoa 事件处理指南中找到:“警告:虽然 NSResponder 声明了许多动作消息,但它实际上并没有实现它们。你不应该直接向响应者对象发送动作消息"那么,再次使用 sendAction 是唯一的方法吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-02-06
  • 1970-01-01
  • 2020-10-31
  • 2021-11-20
  • 1970-01-01
  • 2017-08-08
  • 2012-12-31
相关资源
最近更新 更多