iOS: UITableView not allowing you to reorder items?


I just ran into an interesting problem with UITableView, editing mode, and ECSlidingViewController.

I had an extremely basic UITableView that let the user reorder or delete rows. Everything seemed to be set up fine with the UITableViewDelegate and UITableViewDataSource, but the rows wouldn’t drag!

Turns out that because I was using ECSlidingViewController to create a sliding menu in my app (as is all the rage in 2013/2014), there was a pan gesture recognizer on my view controller that held the table. That pan gesture recognizer normally lets you slide the menu in from the right, but apparently, the UITableView also uses a similar gesture for reordering. The ECSlidingViewController was canceling the touches before the UITableView could get them, so all I had to do to fix the problem was to add one line of code in my view controller’s viewDidLoad: method:

    self.slidingViewController.panGesture.cancelsTouchesInView = NO;

This fixed the issue, and the sliding menu still works on the view controller.

This Stack Overflow page (http://stackoverflow.com/questions/9953706/unable-to-move-rows-in-a-uitableview-even-when-grabber-are-displaying) was the most useful to figure out what was happening with my app.