Hackmodford
Hackmodford

Reputation: 3970

UISearchDisplayController delete Row not deleting

When my microsoftSQL query is successful in deleting a row from the DB I also delete said row from my "local data"

This works as expected unless you are "searching"

When you have the search results displayed and you swipe to delete the row doesn't actually delete with an animation. If I retype my search query it disappears as suspected.

So... is there a way to animate the deletion of a row in a uisearchdisplaycontroller or is there a way to reload the search results table? Or should I just disable being able to delete in searching?

            [itemAutoIDRows removeObjectAtIndex:currentRow];
            [itemIDRows removeObjectAtIndex:currentRow];
            [itemNameRows removeObjectAtIndex:currentRow];
            [qtyOrderedRows removeObjectAtIndex:currentRow];
            [qtyReceivedRows removeObjectAtIndex:currentRow];



            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:currentRow inSection:0];
            NSArray *indexPathArray = [[NSArray alloc] initWithObjects:indexPath, nil];
            [self.POTableView deleteRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationFade];
            break;
            [indexPathArray release];

This code works fine when using just the normal tableview but doesn't animate or refresh the search results table view. Any ideas?

Upvotes: 0

Views: 785

Answers (1)

XJones
XJones

Reputation: 21967

The searchResultsTableView works like any other table view. after you delete the item from it's data source you send deleteRowsAtIndexPaths:withRowAnimation: to it and it should work fine. Your code above is only modifying self.POTableView. The same rules apply as to any tableView, if you modify the data source and want to incrementally update the table view make sure you keep the changes consistent between the data source and the table structure.

Upvotes: 1

Related Questions