Question

Is it possible in code, rather than by the user pressing the screen, to mark a particular cell as being selected?

As you are probably aware the Cells remember their individual background colour and revert to that original colour once they have been superseded/deselected. I need to mark a specific row as selected when a particular TableView loads as it is coming over from a previous screen and wanted to make sure the same cell is highlighted.

Many thanks.

Was it helpful?

Solution

I believe you're looking for UITableView's selectRowAtIndexPath:... instance method.

-[UITableView selectRowAtIndexPath:animated:scrollPosition:]

With this, you can programmatically select any cell. More info in the docs. It's worth noting that there is a matching deselection method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top