困っていること
tableViewを配置したviewControllerで、「編集モード」を実装しようとしました。
まずは、「編集モード」の最低限の機能を確認しようと思い、コードを記入したのですが、
「編集」ボタンを押しても、「完了」ボタンに変化するだけで、cellに何ら変化がありません...
記入したコード(載せています)は、別のviewControllerでは上手く作動したコードであり、
試しに、このviewControllerで記入したコードを、他のviewControllerで試したら上手く作動しました。
一体、何が原因で、このviewControllerでは作動しないのかよく分かりません...
該当のViewControllerのスクショと簡単な機能の説明
勝手に考えていること
このviewControllerでは、tableViewCell(xip)の中にcollectionViewを配置し、
その中でcollectionViewCell(xip)を水平方向にスクロール出来る様にしています。
他の画面にはない機能ですので、それが原因かと思い、その部分の機能を排除して、もう一度実装してみたのですが、
やはり出来ませんでした...
さっぱり原因が分かりません。
自分は初学者でして、ご経験が豊富な方、どうぞご指導ご鞭撻のほどよろしくお願いします。。。
該当のソースコード
コードが長くて、最後まで書くと、10000字を超えてしまいますので、「この部分はどうなっている?」的な質問があれば、教えてください!!!
swift
1 //MARK:Cellの編集(削除)========================================== 2 //MARK:①Cellの編集を許可するか 3 func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { 4 return true 5 } 6 7 8 //MARK:Cellの編集の種類 9 //MARK:①で指定したCellは、通常状態で、スワイプによる削除が可能になるので、その挙動を明示化 10 func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { 11 //MARK:編集状態の時 12 if tableView.isEditing{ 13 return UITableViewCell.EditingStyle.delete 14 //MARK:通常状態の時(スワイプアクション) 15 }else{ 16 return UITableViewCell.EditingStyle.delete 17 } 18 } 19 20 21 //MARK:スワイプ時表示されるボタンのタイトル 22 func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String? { 23 return "削除" 24 } 25 26 27 28 //MARK:Cellの編集の種類毎の処理 29 func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { 30 //MARK:削除ボタンを押した時の処理 31 if editingStyle == .delete{ 32 //MARK:tableViewに反映する配列(配列から特定の順番の要素の消去) 33 //MARK:Cellの削除 34 //MARK:おそらくここでFirebaseの値を更新するのではないか??? 35 } 36 } 37 38 39 40 41 42 43 //MARK:Cellの編集(並び替え)========================================== 44 //MARK:Cellの並び替えを許可するかどうか 45 func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { 46 if indexPath.section == 1{ 47 return true 48 }else{ 49 return false 50 } 51 } 52 53 //MARK:並び替えのつまみから指を離したタイミングで呼ばれるメソッド 54 func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { 55 //MARK:配列の中の順番を変更 56 //MARK:移動先の順番を変更 57 //MARK:このメソッド内ではないが、Firebaseの処理は必要 58 }
あなたの回答
tips
プレビュー