【问题标题】:Swift UITableView Swipe During Scroll AnimationSwift UITableView 在滚动动画期间滑动
【发布时间】:2016-04-28 01:09:34
【问题描述】:
我环顾四周,尝试了所有我能想到的继承 TableView 的方法,但我认为我遗漏了一些东西。我有一个 TableView,其中包含可以左右滑动的条目,一切正常。但是,如果:
1) 我开始(垂直)滚动一点,然后滑动TableView 的超类ScrollView,似乎阻止了我的TableViewCell 滑动。
2) 我停止滚动,但动画没有完全停止,滑动仍然被TableViewCell阻止。
无论垂直滚动如何,我怎样才能让我的滑动传递到我的TableViewCell?
【问题讨论】:
标签:
ios
swift
tableview
scrollview
gesture
【解决方案1】:
Swift 2.2、Xcode 7.3
我基本上通过执行此线程中的建议来解决此问题:Tell ScrollView to Scroll after other pan gesture
下面的代码应该使遇到此线程的其他人能够在表格视图中滚动,并能够滑动,而无需处理表格视图的平移手势识别器阻止滑动,因为仅仅是暗示垂直运动。
希望对某人有所帮助。
所以(在UITableViewController 内——发出的非必要代码):
var lsgr : UISwipeGestureRecognizer!
override func viewDidLoad(){
super.viewDidLoad()
self.lsgr = UISwipeGestureRecognizer(target: self, action: "didSwipeLeft:")
self.lsgr.direction = .Left
self.lsgr.cancelsTouchesInView = false
self.lsgr.delegate = self
}
func didSwipeLeft(leftSwipe: UISwipeGestureRecognizer){
var ip = self.tableView.indexPathForRowAtPoint(leftSwipe.locationOfTouch(0,inView: self.tableView))
print("swipe left - "+String(ip!.row))
}