我可以通过覆盖pressesEnded
方法来检测按键,但如何在遥控器的右侧或左侧按下用户?
答案 0 :(得分:-1)
检查印刷机类型时可以检测到方向性敲击:
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
for press in presses {
switch press.type {
case .upArrow:
print("⬆️")
case .downArrow:
print("⬇️")
default:
super.pressesBegan(presses, with: event)
}
}
}
另一方面,定向点击需要使用GameControler SDK,您可以在此处找到它:https://medium.com/@dcordero/directional-clicks-on-tvos-c711a2faf71a