回答編集履歴

1

s

2017/04/11 23:42

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -1,10 +1,10 @@
1
1
  チェック状態をデータで持つ必要があります、簡単に記述すると以下の様な感じになると思います。
2
+
3
+ ※ 自分作っているデータ配列のクラスにチェック状態のプロパティを追加してみてください。
2
4
 
3
5
 
4
6
 
5
7
  ```swift
6
-
7
-
8
8
 
9
9
  import UIKit
10
10
 
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- tableView.estimatedRowHeight = 20
27
+ tableView.estimatedRowHeight = 44
28
28
 
29
29
  tableView.rowHeight = UITableViewAutomaticDimension
30
30
 
@@ -60,6 +60,8 @@
60
60
 
61
61
 
62
62
 
63
+ // セルにチェック状態を反映
64
+
63
65
  if checkDataArray[indexPath.row] {
64
66
 
65
67
  cell.accessoryType = .checkmark
@@ -86,6 +88,8 @@
86
88
 
87
89
 
88
90
 
91
+ // チェック状態を反転してリロードする
92
+
89
93
  checkDataArray[indexPath.row] = !checkDataArray[indexPath.row]
90
94
 
91
95
  tableView.reloadData()
@@ -94,6 +98,4 @@
94
98
 
95
99
  }
96
100
 
97
-
98
-
99
101
  ```