2

Apple TV の Siri Remote でタッチを収集すると、タッチの場所は常に同じ場所として報告されますか?

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) でさまざまなオプションを試しましたが、何もしませんでした。タップも調べました。デバッガーで何でも見ることができます。

どんなアイデアでも、それはサポートされています。

4

2 に答える 2

1

代わりに touchesBegan メソッドを使用できます。

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    for var touch in touches {
      print(touch.locationInView(self.view))
    }
}
于 2015-11-10T21:56:00.240 に答える
1

これらの方法を使用できます

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)")
    }
}
于 2015-11-17T14:37:52.373 に答える