ios - 如何在表格 View 中访问手指位置/移动信息?
<p><p>所以我想要做的是让我的表格 View 中的每个单元格都能够向左或向右滑动。如果我可以捕获手指位置/翻译,我可以更改内容的 xanchor 和 bingo bango,但我很难弄清楚。如果有人可以提供帮助,那就太好了</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您可以查看有关 <strong>UISwipeGestureRecognizer</strong> 的苹果文档,默认方向是右,也可以探索此功能 <strong>UISwipeGestureRecognizerDirection</strong> 它返回您的方向是右,左,上,或底部。这里是演示</p>
<pre><code>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
}
}
</code></pre>
<p>}</p></p>
<p style="font-size: 20px;">关于ios - 如何在表格 View 中访问手指位置/移动信息?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/47425929/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/47425929/
</a>
</p>
页:
[1]