开发者

Highlight selected row

I have a table view and I would like to highlight the selected cell on the users click how would I do this?

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NS开发者_C百科IndexPath *)indexPath {


The "didSelect..." message is sent to the UITableViewDelegate (your class, once the user has already selected the row). So by the time you have gotten into that function, the row is selected. You do not manually need to select it. Note the description of the "didSelect..." function here.

But you can select rows manually (in general) by sending selectRowAtIndexPath:animated:scrollPosition: to the table view.

You can find out more details from the UITableView documentation.


When a user clicks on a cell, it is automatically highlighted. To unhighlight (as most apps do immediately (to get the 'button click' feel) ) you should use -deselectRowAtIndexPath: animated: as the first line in the didSelectRowAtIndexPath: method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜