我使用此代码检测滑动手势:
let swipeRight = UISwipeGestureRecognizer(target: self, action: Selector("rightSwiped"))
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.matn.addGestureRecognizer(swipeRight)
let swipeLeft = UISwipeGestureRecognizer(target: self, action: Selector("leftSwiped"))
swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
self.matn.addGestureRecognizer(swipeLeft)
let swipeDown = UISwipeGestureRecognizer(target: self, action: Selector("downSwiped"))
swipeDown.direction = UISwipeGestureRecognizerDirection.Down
self.matn.addGestureRecognizer(swipeDown)
let swipeUp = UISwipeGestureRecognizer(target: self, action: Selector("upSwiped"))
swipeUp.direction = UISwipeGestureRecognizerDirection.Up
self.matn.addGestureRecognizer(swipeUp)
func rightSwiped(sender:UISwipeGestureRecognizer)
{
println("right swiped ")
}
func leftSwiped()
{
println("left swiped ")
}
func downSwiped()
{
println("down swiped ")
}
func upSwiped()
{
println("Up swiped ")
}
但{8}在iOS8及更高版本中可用。UISwipeGestureRecognizerDirection
。如何使其与iOS7兼容?
答案 0 :(得分:0)
正如Wain在评论Direction has been available since 3.2
中所提到的,所以你可以在iOS 7中使用它。我已经测试了你的代码,并且它与Deployment target 7.0
一起工作正常。所以你可以在iOS 7中使用它。