teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

コメントによる変更

2018/07/30 06:37

投稿

razuma
razuma

スコア1313

answer CHANGED
@@ -5,7 +5,7 @@
5
5
  ```
6
6
  @IBAction func tapToSend(_ sender: AnyObject) {
7
7
  //全選択解除
8
- for i in 0..<selectCell.count {
8
+ for i in 0..<checkListView.numberOfRows(inSection: 0) {
9
9
  let indexPath = IndexPath(row: i, section: 0)
10
10
  let cell = checkListView.cellForRow(at: indexPath)
11
11
  cell?.accessoryType = .none

1

コメントに対しての追記

2018/07/30 06:37

投稿

razuma
razuma

スコア1313

answer CHANGED
@@ -1,14 +1,19 @@
1
1
  section毎の要素分のindexPathでdeselectRowを呼んであげたらどうでしょうか。
2
2
  (tapToSendの今の状態でチェックが外れるようになっているのであれば。ちょっと試してないのでチェックマーク外す処理入れて再描画みたいなところも現状できるようになっていなかった場合にはそこも対処しなければですね。)
3
3
 
4
- sectionがひとつだけの場合
4
+ sectionがひとつだけの場合。sectionも複数の場合はループを追加してください。
5
5
  ```
6
6
  @IBAction func tapToSend(_ sender: AnyObject) {
7
7
  //全選択解除
8
- for i in 0..<tableViewItem.count {
8
+ for i in 0..<selectCell.count {
9
- let indexPath = IndexPath(row: i, section: 0)
9
+ let indexPath = IndexPath(row: i, section: 0)
10
+ let cell = checkListView.cellForRow(at: indexPath)
11
+ cell?.accessoryType = .none
10
12
  checkListView.deselectRow(at: indexPath, animated: true)
11
13
  }
12
- reloadInputViews()
13
14
  }
14
- ```
15
+ ```
16
+
17
+ 回答追記:
18
+ `cell?.accessoryType = .none`もやる必要がありだったので書き直しました。
19
+ わからない部分や動かない点があったら教えてください。