Reputation: 147
I wanted to do some feed like in Facebook. Feed i make like table view with customs cells. And added a panel in each cell, which u can drag down and find some more buttons. I added UIPanGestureRecognizer to it. The problem is that when i'm programming Gesture i cannot get cell where i m dragging. Rowdidselected doesn't work. I need to get a cell, so i can drag my panel and make some bounds, so it cannot be moved through full screen. Just about 30 down, not more. It will be cool, if i could change height of current row too
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)
}
Upvotes: 0
Views: 581
Reputation: 578
Are you just trying to get the cell where your gesture registered? After you get the indexPath:
let cell: YourCellClass = self.tableView.cellForRowAtIndexPath(indexPath)
cell.doWhatever()
Upvotes: 2