Skip to content

Commit

Permalink
Stronger failsafe on accepting long press gesture — short-circuits if…
Browse files Browse the repository at this point in the history
… there is no highlighted cell.
  • Loading branch information
shusta committed May 10, 2011
1 parent 2dfd77a commit 51e3113
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ATSDragToReorderTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ - (void)longPressRecognized {
if ( !(indexPathOfRow.section == selectedPath.section && indexPathOfRow.row == selectedPath.row) )
indexPathOfRow = selectedPath;

/*
* For some other reason the cell isn't highlighed
*/
UITableViewCell *highlighedCell = [self.tableView cellForRowAtIndexPath:indexPathOfRow];
if ( ![highlighedCell isHighlighted] )
return;

/*
* Check to see if the tableView's data source will let us move this cell.
* Return if the data source says NO.
Expand Down Expand Up @@ -473,6 +480,7 @@ - (void)longPressRecognized {
* Why not just [self.draggedCell setSeparatorStyle:self.tableView.separatorStyle] ourselves? That's a private method.
*/


NSIndexPath *indexPathOfSomeOtherRow = [self indexPathOfSomeRowThatIsNotIndexPath:indexPathOfRow];

if (indexPathOfSomeOtherRow != nil)
Expand Down

0 comments on commit 51e3113

Please sign in to comment.