通过已知的 NSIndexPath swift 获取单元格
get cell by known NSIndexPath swift
我想像在 Facebook 中那样做一些提要。我用海关单元格制作的 Feed 就像 table 视图一样。并在每个单元格中添加了一个面板,您可以向下拖动它并找到更多按钮。我向其中添加了 UIPanGestureRecognizer。问题是,当我对 Gesture 进行编程时,我无法获得我拖动的单元格。 Rowdidselected 不起作用。我需要一个单元格,这样我就可以拖动我的面板并设置一些界限,这样它就不能全屏移动了。大约下降了 30 个,而不是更多。如果我也可以更改当前行的高度,那会很酷
func handlePan(recognizer:UIPanGestureRecognizer) {
let translation = recognizer.translationInView(self.view)
let possition = recognizer.locationInView(self.tableView)
var index : NSIndexPath? = self.tableView.indexPathForRowAtPoint(possition)
recognizer.view!.center = CGPoint(x:recognizer.view!.center.x,
y:recognizer.view!.center.y + translation.y)
recognizer.setTranslation(CGPointZero, inView: self.view)
}
你只是想获取你的手势注册的单元格吗?获得 indexPath 后:
let cell: YourCellClass = self.tableView.cellForRowAtIndexPath(indexPath)
cell.doWhatever()
我想像在 Facebook 中那样做一些提要。我用海关单元格制作的 Feed 就像 table 视图一样。并在每个单元格中添加了一个面板,您可以向下拖动它并找到更多按钮。我向其中添加了 UIPanGestureRecognizer。问题是,当我对 Gesture 进行编程时,我无法获得我拖动的单元格。 Rowdidselected 不起作用。我需要一个单元格,这样我就可以拖动我的面板并设置一些界限,这样它就不能全屏移动了。大约下降了 30 个,而不是更多。如果我也可以更改当前行的高度,那会很酷
func handlePan(recognizer:UIPanGestureRecognizer) {
let translation = recognizer.translationInView(self.view)
let possition = recognizer.locationInView(self.tableView)
var index : NSIndexPath? = self.tableView.indexPathForRowAtPoint(possition)
recognizer.view!.center = CGPoint(x:recognizer.view!.center.x,
y:recognizer.view!.center.y + translation.y)
recognizer.setTranslation(CGPointZero, inView: self.view)
}
你只是想获取你的手势注册的单元格吗?获得 indexPath 后:
let cell: YourCellClass = self.tableView.cellForRowAtIndexPath(indexPath)
cell.doWhatever()