2015-11-10 101 views
1

當在Apple TV上收集Siri Remote上的觸摸時,觸摸的位置總是作爲相同的位置報告回來?Siri遠程觸摸位置?

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)中的各種選項,但沒有。還檢查了水龍頭。在調試器中可以看到任何東西。

任何想法,是否支持。

+1

發現這個在這裏http://www.marisibrothers.com/2015/10/interacting-with -new-apple-tv-remote.html所以看起來像我不能 – J0hnnieMac

回答

1

可以使用的touchesBegan方法代替:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
    for var touch in touches { 
     print(touch.locationInView(self.view)) 
    } 
} 
+0

不幸的是,它總是報告相同的touchLocation :(這一切都顯得有點奇怪,因爲它都是基於屏幕輸入而不是觸控板輸入。也許在未來發布。 – J0hnnieMac

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)") 
    } 
}