Cesare Cesare - 2 years ago 146
iOS Question

What is clearsSelectionOnViewWillAppear for?

is a boolean property of table and collection views, and it's
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?

Answer Source

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.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download