###前提・実現したいこと
swiftでスワイプで、完了/削除のできるテーブルを作成したいです。
###発生している問題
MCSwipeTableViewCellを使用してスワイプまでは実装できましたが、
スワイプ後の削除方法がわからず。。。
おそらく基本的なことかと思いますが、調べてみると「ボタン押下で削除」系の記事が多く、
ご教授頂ければと思います。
###ソースコード
swift
1import UIKit 2import MCSwipeTableViewCell 3 4class ViewController: UIViewController,UITableViewDataSource { 5 6 var dataList = ["task01","task02", "task03","task04"] 7 8 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 9 // create 10 var cell = tableView.dequeueReusableCellWithIdentifier("cell") as? MCSwipeTableViewCell 11 if cell == nil { 12 cell = MCSwipeTableViewCell(style: .Subtitle, reuseIdentifier: "cell") 13 } 14 15 // setup 16 cell!.selectionStyle = .None 17 cell!.textLabel?.text = dataList[indexPath.row] 18 cell!.detailTextLabel?.text = "details..." 19 cell?.detailTextLabel?.textColor = .lightGrayColor() 20 cell!.defaultColor = .lightGrayColor() 21 cell!.firstTrigger = 0.25; 22 23 // listeners 24 cell!.setSwipeGestureWithView(UIImageView(image: UIImage(named: "check")!), color: .greenColor(), mode: .Exit, state: .State1, completionBlock: { (cell: MCSwipeTableViewCell!, state: MCSwipeTableViewCellState!, mode: MCSwipeTableViewCellMode!) -> Void in 25 print("check") 26 }) 27 28 cell!.setSwipeGestureWithView(UIImageView(image: UIImage(named: "clock")!), color: .purpleColor(), mode: .Exit, state: .State3, completionBlock: { (cell: MCSwipeTableViewCell!, state: MCSwipeTableViewCellState!, mode: MCSwipeTableViewCellMode!) -> Void in 29 print("clock") 30 }) 31 32 return cell! 33 } 34 35 36 37 func tableView(tableView:UITableView, numberOfRowsInSection section:Int) -> Int { 38 return dataList.count 39 } 40 41 override func viewDidLoad() { 42 super.viewDidLoad() 43 } 44 45}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/12 12:24
2017/03/12 12:27
2017/03/12 13:01
2017/03/12 13:52
2017/03/13 13:52
2017/03/13 14:01
2017/03/13 14:05
2017/03/13 14:12 編集
2017/03/13 14:18
2017/03/13 14:29
2017/03/13 14:47
2017/03/13 14:52
2017/03/13 14:53
2017/03/13 14:55
2017/03/13 14:59
2017/03/13 15:00
2017/03/13 15:10