我正在使用此代码检测刷卡手势:

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

但是UISwipeGestureRecognizerDirection在iOS8和更高版本中可用。如何使其与iOS7兼容?

最佳答案

正如Wain在评论中提到的,Direction has been available since 3.2这样你就可以在iOS 7中使用它。我已经用Deployment target 7.0测试了您的代码及其正常工作。所以你可以在iOS7上使用它。

关于ios - Swift:检测与iOS 7兼容的滑动手势,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30411122/

10-13 09:27