How can i highlight a uitableviewcell only for a specific period of time without selecting it? I need to keep a cell highlighted for suppose 3 seconds and it then get dehighlighted. Basically i am developing a book type application where cells are in synch with audio. i have populated the tableviewcells with text and also I have timings for how long to keep a cell highlighted.
The API for setting a UITableViewCell
's highlight state is setHighlighted:animated:
so assuming you just need a simple highlight the work is half done.
Using the UITableViewDelegate
method tableView:willDisplayCell:forRowAtIndexPath:
, notify the cell that it has become visible through some method you define in the subclass. That method will cause the cell to highlight itself and start a timer for as long as you want the cell to remain highlighted. When the timer fires, cause the cell to remove the highlight.
You will of course have to guard against timers remaining active if a cell scrolls out of view, so invalidate timers and reset the highlight state during prepareForReuse: