回答編集履歴
2
Bool値が逆だった
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
cell.detailTextLabel?.hidden = self.isShowDetailTextLabel
|
21
|
+
cell.detailTextLabel?.hidden = !self.isShowDetailTextLabel
|
22
22
|
|
23
23
|
|
24
24
|
|
1
実際の実装想定となるコードを追加
test
CHANGED
@@ -1 +1,39 @@
|
|
1
1
|
手っ取り早いのはセルを使ってるViewControllerクラス側でdetailTextLabelの表示フラグを持っておくことですかね、cellForRowAtIndexPath関数内で表示フラグを見てdetailTextLabelを表示するかどうかの処理を書いておいて、表示フラグが切り替わったタイミングでreloadDataを呼び出すとうまくいくのではないでしょうか
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```Swift
|
6
|
+
|
7
|
+
var tableView: UITableView!
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
var isShowDetailTextLabel = false // falseとしてますが初期値としたいBool値で
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
16
|
+
|
17
|
+
let cell = tableView.dequeueReusableCellWithIdentifier("cellIdentifier", forIndexPath: indexPath) as! UITableViewCell
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
cell.detailTextLabel?.hidden = self.isShowDetailTextLabel
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
return cell
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
@IBAction func test(sender: AnyObject) {
|
32
|
+
|
33
|
+
self.isShowDetailTextLabel = !self.isShowDetailTextLabel
|
34
|
+
|
35
|
+
self.tableView.reloadData()
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
```
|