swift
1func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { 2 3 let edit = UIContextualAction(style: .normal,title: "追加", handler: { (action: UIContextualAction, view: UIView, success :(Bool) -> Void) in 4 5 let alert = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: .alert) 6 7 // OKボタンの設定 8 let okAction = UIAlertAction(title: "OK", style: .default, handler: { 9 (action:UIAlertAction!) -> Void in 10 11 // OKを押した時入力されていたテキストを表示 12 if let textFields = alert.textFields { 13 14 // アラートに含まれるすべてのテキストフィールドを調べる 15 for textField in textFields { 16 let name = textField.text! 17 let index = Int(floor(Double(indexPath.row / 2))) 18 19 self.products[index].detail.append(name) 20 self.mytableView.reloadData() 21 } 22 } 23 }) 24 alert.addAction(okAction) 25 26 // キャンセルボタンの設定 27 let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) 28 alert.addAction(cancelAction) 29 30 // テキストフィールドを追加 31 alert.addTextField(configurationHandler: {(textField: UITextField!) -> Void in 32 textField.placeholder = "テキスト" 33 }) 34 35 36 alert.view.setNeedsLayout() // シミュレータの種類によっては、これがないと警告が発生 37 38 // アラートを画面に表示 39 self.present(alert, animated: true, completion: nil) 40 print("edit") 41 42 success(true) 43 }) 44 45 edit.backgroundColor = .blue 46 47 return UISwipeActionsConfiguration(actions: [edit]) 48 }
やりたい事
cellをスワイプした時に引っ張りすぎるとスワイプの処理が実行されるのでスワイプだけで処理が実行されない様にしたい。
理想としては、cellをスワイプしてからスワイプをタップして初めて処理が実行される様にしたい。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/05/19 00:47
退会済みユーザー
2018/05/19 08:52