开发者

Highlight selected row

开发者 https://www.devze.com 2023-02-05 08:47 出处:网络
I have a table view and I would like to highlight the selected cell on the users click how would I do this?

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

精彩评论

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

关注公众号