Select selected row

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

(void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {

thanks

Mason

+4
source share
2 answers

The message "didSelect ..." is sent to the UITableViewDelegate (your class, as soon as the user has already selected the row). Thus, by the time you enter this function, the row will be selected. You do not need to manually select it. Pay attention to 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 learn more from the UITableView documentation .

+5
source

When the user clicks on a cell, it is automatically highlighted. In order not to make fun of it (as most applications do (to get a β€œclick of a button”), you should use -deselectRowAtIndexPath: animated: as the first line in the didSelectRowAtIndexPath: method.

+2
source

Source: https://habr.com/ru/post/1336212/


All Articles