所以我想要做的是让我的表格 View 中的每个单元格都能够向左或向右滑动。如果我可以捕获手指位置/翻译,我可以更改内容的 x anchor 和 bingo bango,但我很难弄清楚。如果有人可以提供帮助,那就太好了
您可以查看有关 UISwipeGestureRecognizer 的苹果文档,默认方向是右,也可以探索此功能 UISwipeGestureRecognizerDirection 它返回您的方向是右,左,上,或底部。这里是演示
var swipeRight = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRight)
var swipeDown = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeDown.direction = UISwipeGestureRecognizerDirection.Down
self.view.addGestureRecognizer(swipeDown)
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.Right:
print("Swiped right")
case UISwipeGestureRecognizerDirection.Down:
print("Swiped down")
case UISwipeGestureRecognizerDirection.Left:
print("Swiped left")
case UISwipeGestureRecognizerDirection.Up:
print("Swiped up")
default:
break
}
}
}
关于ios - 如何在表格 View 中访问手指位置/移动信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47425929/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |