Hide shortcut when UITableView Cell is connected

I have a label inside my cells that I would like to show / hide when used. I know that I need to get the index path of the cell that was retrieved from didSelectRowAtIndexPath

. But I'm not sure how I then show / hide the label in that particular cell.

Is it possible to show / hide it from didSelectRowAtIndexPath

, or is there a way to deal with it in cellForRowAtIndexPath

and then update it?

I've done some research on this, but I really couldn't find much.

Here's everything I have so far:

var selectedRowIndex: NSIndexPath = NSIndexPath(forRow: -1, inSection: 0)

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    selectedRowIndex = indexPath
}

      

+3


source to share


1 answer


This is how you get to the cell along the pointer path:

let cell = tableView.cellForRowAtIndexPath(indexPath) as MyCustomCell
cell.myTextLabel.hidden = true

      



In addition, depending on your needs, you can also deselect a cell.

tableView.deselectRowAtIndexPath(indexPath)

      

+10


source







All Articles