3

tvOSでリモコンの強制的なタッチ/クリックを検出する方法を知っている人はいますか?

スプライト キット シーンでクリックを使用して、「ゲーム一時停止アラート」を開きたいです。フォーカスがあり、クリックに反応するUIKitコントロールはありません。

リモコンの「通常の」タッチイベントを使用して、スプライトを移動しています。

4

1 に答える 1

2

Apple はUIPressesEvent、プレス/クリックを検出するために 's を使用することを提案しています。

override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    for item in presses {
        if item.type == .Select {
            self.view.backgroundColor = UIColor.greenColor()
        }
    }
}

override func pressesEnded(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    for item in presses {
        if item.type == .Select {
            self.view.backgroundColor = UIColor.whiteColor()
        }
    }
}

override func pressesChanged(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    // ignored
}

override func pressesCancelled(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
    for item in presses {
        if item.type == .Select {
            self.view.backgroundColor = UIColor.whiteColor()
        }
    }
}
于 2015-09-28T12:18:23.200 に答える