Swift Siri远程触摸定位?
当在苹果电视上的Siri遥控器上收集触摸时,触摸的位置总是作为相同的位置报告回来Swift Siri远程触摸定位?,swift,uigesturerecognizer,tvos,apple-tv,siri-remote,Swift,Uigesturerecognizer,Tvos,Apple Tv,Siri Remote,当在苹果电视上的Siri遥控器上收集触摸时,触摸的位置总是作为相同的位置报告回来 let tapRecognizer = UITapGestureRecognizer(target: self, action: "tapped:") tapRecognizer.allowedPressTypes = [NSNumber(integer: UIPressType.LeftArrow.rawValue),NSNumber(integer: UIPressType.RightArrow.raw
let tapRecognizer = UITapGestureRecognizer(target: self, action: "tapped:")
tapRecognizer.allowedPressTypes = [NSNumber(integer: UIPressType.LeftArrow.rawValue),NSNumber(integer: UIPressType.RightArrow.rawValue)];
self.view.addGestureRecognizer(tapRecognizer)
func tapped(tap :UITapGestureRecognizer){
print(__FUNCTION__)
print(tap.locationInView(super.view))
}
在locationInView(xxx)中尝试了各种选项,但什么也没有尝试。还检查了tap。在调试器中,可以看到任何内容
支持任何想法。您可以使用ToucheSBegind方法:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for var touch in touches {
print(touch.locationInView(self.view))
}
}
覆盖函数触摸开始(触摸:设置,withEvent事件:UIEvent?){
对于var触控触控{
打印(touch.locationInView(self.view))
}
}
您可以使用这些方法
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
print("touchesBegan: x: \(location.x) y: \(location.y)")
}
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
print("touchesMoved: x: \(location.x) y: \(location.y)")
}
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
print("touchesEnded: x: \(location.x) y: \(location.y)")
}
}
覆盖函数触摸开始(触摸:设置,withEvent事件:UIEvent?){
接触{
let location=touch.locationInNode(自)
打印(“触摸开始:x:\(location.x)y:\(location.y)”)
}
}
覆盖功能触摸移动(触摸:设置,带事件:UIEvent?){
接触{
let location=touch.locationInNode(自)
打印(“触摸移动:x:\(location.x)y:\(location.y)”)
}
}
覆盖func touchesEnded(触摸:设置,withEvent事件:UIEvent?){
接触{
let location=touch.locationInNode(自)
打印(“touchesEnded:x:\(location.x)y:\(location.y)”)
}
}
我在这里找到了这个,所以看起来我无法找到。幸运的是,它总是报告相同的触摸位置:(这一切看起来有点奇怪,因为它都是基于屏幕输入,而不是触摸板输入。也许在未来的版本中。