Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the point of showsReorderControl?

I've got a UITableView instance and implemented:

tableView:canEditRowAtIndexPath:
tableView:editingStyleForRowAtIndexPath:
tableView:shouldIndentWhileEditingRowAtIndexPath:
tableView:canMoveRowAtIndexPath:
tableView:moveRowAtIndexPath:toIndexPath:

After that I can see all my cells with reorder controls.

Apple's header says:

@property(nonatomic) BOOL showsReorderControl; // default is NO

If the default value is NO why am I seeing the reorder controls?

Update: I've also checked the value of property in tableView:cellForRowAtIndexPath: right after when the cell is created:

(lldb) p [c showsReorderControl]
(BOOL) $1 = NO
like image 476
Rudolf Adamkovič Avatar asked Dec 01 '12 13:12

Rudolf Adamkovič


2 Answers

When you return YES from tableView:canMoveRowAtIndexPath:, it does the same thing as setting the showsReorderControl to YES. These are just two different ways to enable the reorder control.

In fact, there is a third way - let's never complain that we don't have options! ;) From the documentation of tableView:canMoveRowAtIndexPath::

This method allows the delegate to specify that the reordering control for a the specified row not be shown. By default, the reordering control is shown if the data source implements the tableView:moveRowAtIndexPath:toIndexPath: method.

like image 162
J Shapiro Avatar answered Nov 07 '22 20:11

J Shapiro


By reading the current Apple docs, it seems showsReorderControl has no use at all.

UITableViewCell

For the reordering control to appear, you must not only set this property but implement the UITableViewDataSource method tableView:moveRowAtIndexPath:toIndexPath:.

UITableViewDataSource

By default, the reordering control is shown if the data source implements the tableView:moveRowAtIndexPath:toIndexPath: method.

From this documentation I conclude that:

1- The only way to show the reordering control is by implementing tableView:moveRowAtIndexPath:toIndexPath:, which shows the control in all cells.

2- If you want a cell to not display the control, you must return NO from tableView:canMoveRowAtIndexPath:

3- showsReorderControl has no control on wether or not the reorder control is shown.

like image 2
Mark Avatar answered Nov 07 '22 20:11

Mark