tvOSでリモコンの強制的なタッチ/クリックを検出する方法を知っている人はいますか?
スプライト キット シーンでクリックを使用して、「ゲーム一時停止アラート」を開きたいです。フォーカスがあり、クリックに反応するUIKitコントロールはありません。
リモコンの「通常の」タッチイベントを使用して、スプライトを移動しています。
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()
}
}
}