2015-11-10 2 views
1

При сборе касаний на Siri Remote на Apple TV местоположение касания всегда сообщается как одно и то же местоположение?Siri Remote Touch Location?

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)") 
    } 
} 
Смежные вопросы