3

I have a simple tableview with cell like this.

enter image description here

Now I want to implement drag drop in this table view so that user can arrange cells. So I used this.

func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return true
}

func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
    return UITableViewCellEditingStyle.None
}

func tableView(tableView: UITableView, shouldIndentWhileEditingRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return false
}

func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) {
    let card = self.arrCards.objectAtIndex(sourceIndexPath.row) as! Card
    self.arrCards.removeObjectAtIndex(sourceIndexPath.row)
    self.arrCards.insertObject(card, atIndex: destinationIndexPath.row)
}

Its showing the cell like this.

enter image description here

So here I don't want the three line button. How can I remove that button. I want the drag drop should happen when user is dragging the whole cell. I have tried to change accessoryType, editingAccessoryType, accessoryView, editingAccessoryView. But no luck till yet.

Janmenjaya
  • 4,149
  • 1
  • 23
  • 43
Mahesh Agrawal
  • 3,348
  • 20
  • 34
  • The answer in this [question](http://stackoverflow.com/questions/8603359/change-default-icon-for-moving-cells-in-uitableview/8603664#8603664) it should be help you removing the view instead of changing it's image. – Victor Sigler Oct 05 '16 at 03:04
  • that answer is to change the image of that reorder button but i want to completely remove it. But after searching i found that its a private and i cannot remove it. Otherwise apple will reject the app. So the better way i found is implementing long press gesture and creating a snapshot of cell and moving it with pan. thank you for reference. – Mahesh Agrawal Oct 05 '16 at 03:24
  • removing the view still occupies the space which i cannot change i guess. – Mahesh Agrawal Oct 05 '16 at 03:26
  • Your question is confusing. Do you want to implement the standard `UITableView` row reordering or do you want a custom reordering using gesture recognizers? – rmaddy Oct 05 '16 at 04:25
  • i wanted standard reordering but without changing the look of my cell and i wanted the user to drag and rearrenge the cell by tapping anywhere on the cell – Mahesh Agrawal Oct 05 '16 at 04:30
  • That's a contradiction. You either use standard table reordering using the standard `UITableView` data source and delegate methods with the standard reordering control at the right end of the cell or you use of none of that and implement your own completely custom approach. – rmaddy Oct 05 '16 at 04:36
  • i am getting the same issue is there any solution? – Deepak Saki Nov 15 '17 at 13:49
  • i could not get any solution, so i used default ones. but there is ways of using custom. unfortunately i did not tried. – Mahesh Agrawal Nov 16 '17 at 18:33

0 Answers0