【问题标题】:canPerformAction:with sender method called on tap in ios 9canPerformAction:在 ios 9 中调用发送方方法
【发布时间】:2015-10-16 09:31:37
【问题描述】:

我在 iOS 9.0 中观察到的一件事是,当我点击按钮或 TableView 时,canPerformMethod:withSender: 方法被调用,发送者为 UIButton 类型。我正在使用这种方法来准备我的自定义选项菜单。

我在以前的 iOS 中没有观察到这一点。任何人都可以看到我的 API 更改,因为我经历了 iOS 的整体更改,但我没有在更改日志或更改历史记录中找到上述更改。

【问题讨论】:

    标签: ios uibutton uimenucontroller uiresponder


    【解决方案1】:

    Apple Documentation

    iOS 3.0 引入了用于生成运动事件的系统功能, 特别是摇动设备的动作。事件处理 这类事件的方法是 motionBegan:withEvent:, motionEnded:withEvent: 和 motionCancelled:withEvent:。此外 对于 iOS 3.0,canPerformAction:withSender: 方法允许响应者 验证用户界面中的命令,而 undoManager 属性返回响应者中最近的 NSUndoManager 对象 链。

    因此,所有UIResponder 子类都有权收到canPerformAction:withSender: 的回电。在这个方法中你应该使用sender参数来做处理。

    【讨论】:

    • Abinav,我检查了文档,我完全同意从 UIResponder 类继承的每个元素都将执行 canPerformAction 方法。然后我检查了我的代码,这种方法在以前的 iOS 中没有出现。你能检查一下吗?
    • 因为我目前观察到的是当我点击按钮或 TableView 时,canPerformAction:withSender: 方法命中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 2018-05-26
    • 1970-01-01
    相关资源
    最近更新 更多