Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does clearsSelectionOnViewWillAppear do?

clearsSelectionOnViewWillAppear is a boolean property of table and collection views, and it's set to true by default. According to the Apple Reference:

A Boolean value indicating if the controller clears the selection when the table appears.

What does that mean?

like image 737
Cesare Avatar asked Jun 24 '15 19:06

Cesare


1 Answers

Let's say that, as is usual, you tap a cell and this presents a new view controller. Okay, but how does it do that? Your tap selects the cell. That is a visible change in the cell - the cell is highlighted.

Later, you dismiss that view controller and return to your table / collection view.

The question is: should the selection (caused by your earlier tap) still be showing as a selection? Should the cell still be visibly highlighted? The default is: no. We clear the selection before you visibly return to the table / collection view.

(You could do this yourself in your viewWillAppear: implementation, but the table / collection view controller is willing to do it for you.)

like image 115
matt Avatar answered Oct 18 '22 09:10

matt