【发布时间】:2016-07-30 10:21:59
【问题描述】:
有没有办法在 ViewController 中检测 TableView 上的上下滑动?
在ViewDidLoad();
let upSwipe = UISwipeGestureRecognizer(target: self, action: Selector("swipeUp:"))
let downSwipe = UISwipeGestureRecognizer(target: self, action: Selector("swipeDown:"))
upSwipe.direction = .Up
downSwipe.direction = .Down
tableView.addGestureRecognizer(upSwipe)
tableView.addGestureRecognizer(downSwipe)
很遗憾,这不起作用。
func swipeDown() {
print("A")
}
没有返回。
在 TableView(不是单元格/作为一个整体)上检测手势的适当方法是什么?
【问题讨论】:
-
@BLE 我要的是 Swift
-
道歉,但这主要是语义上的。您要查找的信息位于 developer.apple.com
scrollViewDidScroll(_:)上文档的 UIScrollViewDelegate 部分 -
@BLE 我尝试了this answer,但无法成功:/我做错了什么?
-
没有用怎么办?你在
func scrollViewDidScroll(scrollView: UIScrollView!) { }里面放了什么吗?
标签: ios swift uitableview uigesturerecognizer