gpt4 book ai didi

ios - Swift:检测与 iOS 7 兼容的滑动手势

转载 作者:行者123 更新时间:2023-11-28 09:07:34 25 4
gpt4 key购买 nike

我正在使用此代码来检测滑动手势:

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

enter image description hereUISwipeGestureRecognizerDirection 在 iOS8 及更高版本中可用。如何让它与 iOS7 兼容?

最佳答案

正如 Wain 在评论中提到的那样,Direction 从 3.2 开始可用,因此您可以将它与 iOS 7 一起使用。我已经测试了您的代码,并且它在 Deployment target 7.0 上运行良好>。所以你可以在 iOS 7 上使用它。

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com