2015-09-18 1 views
0

J'ai personnalisé UITableViewCell avec du contenu dessus. Pendant que j'essaie de balayer (pour afficher le bouton personnalisé avec image) Cela ne fonctionne tout simplement pas, ou si je vais essayer de le faire 10 fois, pour que je puisse voir l'action du bouton de suppression par glissement.editActionsForRowAtIndexPath swipe numéro

mon code est:

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

    func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 
     // 
    } 


    func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { 


     let cell = tableView.cellForRowAtIndexPath(indexPath) as! MessagesCell 

     let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Destructive, title: "  ") { value in 

      // here some removing action 
     deleteAction.backgroundColor = UIColor(patternImage: UIImage(named: "swipeToDelete")!) 
     return [deleteAction] 
    } 

my table cell

Répondre

0

Le problème était dans IIViewDeckController qui bloqué glisser avec son PanGesture

0

Ce code aidera

func tableView(tableView: UITableView!, canEditRowAtIndexPath indexPath: NSIndexPath!) -> Bool { 
return true 

}

func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) { 
    if (editingStyle == UITableViewCellEditingStyle.Delete) { 
     // handle delete (by removing the data from your array and updating the tableview) 
    } 
} 

Merci.

+0

Ce ne sera pas le cas. Parce que j'utilise pour supprimer une autre méthode editActionsForRowAtIndexPath, qui peut implémenter l'image personnalisée pour le bouton d'action de suppression – Anton