在 TableView 上检测滑动手势
Detecting Swipe Gestures on TableView
有没有办法检测 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(不是 cell/as 整体)上检测手势的合适方法是什么?
实现 UIScrollViewDelegate
定义scrollViewDidScroll(_:)
将您的 tableview 的 scrollview 的委托设置为您在其中定义了上述内容的任何对象。
有没有办法检测 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(不是 cell/as 整体)上检测手势的合适方法是什么?
实现 UIScrollViewDelegate
定义scrollViewDidScroll(_:)
将您的 tableview 的 scrollview 的委托设置为您在其中定义了上述内容的任何对象。