I am trying to update UITableViewCell's border when the user performs a long press gesture on the cell, but it's not updating.
Here is my cellForRowAtIndexPath:
method
let objLongPressHandler = UILongPressGestureRecognizer(target: self, action: #selector(self.longPressHandler(_:)))
objLongPressHandler.view?.tag = indexPath.row
objLongPressHandler.delegate = self
objLongPressHandler.enabled = true
objLongPressHandler.minimumPressDuration = 0.1
cell.contentView.addGestureRecognizer(objLongPressHandler)
This is my function UILongPressGestureRecognizer
function.
func longPressHandler(objGesture: UILongPressGestureRecognizer) {
let center = objGesture.view?.center
let rootViewPoint = objGesture.view!.superview?.convertPoint(center!, toView: self.tableView)
let indexPath = self.tableView.indexPathForRowAtPoint(rootViewPoint!)
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath!) as! GroupTableViewCell
cell.contentView.layer.borderColor = UIColor.redColor().CGColor
cell.contentView.layer.borderWidth = 3
cell.setNeedsLayout()
}