2016-12-03 3 views
0

私はIndexPath.rowに応じてカスタムUITableViewRowActionを設定する方法は? UITableViewCellの:

  • のtableView(のUITableView)
  • customCellを持っています!
  • itemsArrayの:[項目]

私はIndexPath.rowに応じてのUITableViewでセルのためのカスタムアクションを設定しようとしました。

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) 
-> [UITableViewRowAction]? { 

    if !(itemsArray[indexPath.row].isReadOnly) { 

    let editAction = UITableViewRowAction(style: .normal, title: "Edit") { 
     (tableViewRowAction, indexPath) in 
     print("Edit Item \(self.itemsArray[indexPath.row].caption)\n") 
    }  
    return [editAction] 
    } else { 
    return [] 
    } 
} 

私はIndexPath.rowに応じてのUITableViewでセルのためのカスタムアクションを設定しようとしました:

問題は.isReadOnly = trueを持つ対応するアイテム(アクションなしに私はなりたい細胞と発生バックセルが少しスワイプ、「unswipes」[ - ] - ゼロ - - アクションを削除アイテム ため示し を:私はゼロを返すようにしようとした[]他の場合、両方の変異体でスワイプは無関係結果た)

スワイプ以上が働いていない任意のセル

答えて

0

は私が解決策を見つけた:ただのUITableView

func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { 
    return !(items[indexPath.row].isReadOnly) 
} 
のcanEditRowAtメソッドを使用します
関連する問題