代码之家  ›  专栏  ›  技术社区  ›  Sunil Targe

UI按键事件按键类型选择在swift中不起作用

  •  0
  • Sunil Targe  · 技术社区  · 5 年前
    override open func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
        for press in presses {
            if press.type == .select {
                self.view.backgroundColor = .red // NOT BEING CALLED
            } else if press.type == .playPause {
                self.view.backgroundColor = .blue
            } else {
                self.view.backgroundColor = .yellow
            }
        }
    }
    

    在上面的代码中,所有事件都运行良好,但 Select 事件不起作用。 当按键盘上的ENTER键检测tvOS表面点击时,应该会调用它。

    上面的代码有什么问题。

    0 回复  |  直到 5 年前