I am trying to detect the swipes on the AppleWatch on all four directions. Yet I am not clear how to assign many values to the direction of the WKSwipeGestureRecognizer I inserted in the Storyboard. I tried with:
swiper.direction = [.right , .left , .up , .down]
that was funnily accepted by the compiler, differently of using the bitwise |, but, using this configuration, function:
@IBAction func swipe(_ sender: Any) {
switch swiper.direction {
case WKSwipeGestureRecognizerDirection.right:
print("Swiped right")
case WKSwipeGestureRecognizerDirection.down:
print("Swiped down")
case WKSwipeGestureRecognizerDirection.left:
print("Swiped left")
case WKSwipeGestureRecognizerDirection.up:
print("Swiped up")
default:
break
}
}
is very seldom called and when it is the swiper.direction is invariably .right.
Apple is very cryptic at: https://developer.apple.com/reference/watchkit/wkswipegesturerecognizer/1650828-direction by saying:
"The default value of this property is right. You may specify more than one direction to track swipes in multiple directions with the same gesture recognizer."
without revealing how.