質問編集履歴

1

コードの追加

2016/09/07 02:46

投稿

M.minoru
M.minoru

スコア19

test CHANGED
File without changes
test CHANGED
@@ -55,3 +55,111 @@
55
55
  またもし高さ変更ができないのであればできないと回答が欲しいです。
56
56
 
57
57
  宜しくお願いします。
58
+
59
+
60
+
61
+ 追加のコード
62
+
63
+ ```
64
+
65
+ import UIKit
66
+
67
+
68
+
69
+ class ViewController: UITableViewController{
70
+
71
+
72
+
73
+ @IBOutlet var table: UITableView!
74
+
75
+ var height: CGFloat = 0.0
76
+
77
+ var num = 0
78
+
79
+
80
+
81
+ override func viewDidLoad() {
82
+
83
+ super.viewDidLoad()
84
+
85
+ }
86
+
87
+
88
+
89
+ override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
90
+
91
+ {
92
+
93
+ if num == 0{
94
+
95
+ if indexPath.section == 0 && indexPath.row == 4 {
96
+
97
+ num += 1
98
+
99
+ return 0
100
+
101
+ }
102
+
103
+ if indexPath.section == 0 && indexPath.row >= 1 {
104
+
105
+ return 0
106
+
107
+ }
108
+
109
+ else {
110
+
111
+ if indexPath.section == 0 && indexPath.row == num {
112
+
113
+ return 50
114
+
115
+ }
116
+
117
+ }
118
+
119
+ }
120
+
121
+
122
+
123
+ if indexPath.section == 0 && indexPath.row >= num{
124
+
125
+ return 0
126
+
127
+ }
128
+
129
+ return 50
130
+
131
+ }
132
+
133
+
134
+
135
+ @IBAction func pushButton(sender: AnyObject) {
136
+
137
+ num += 1
138
+
139
+ heightChanger()
140
+
141
+ }
142
+
143
+
144
+
145
+ func heightChanger() {
146
+
147
+ if num <= 3{
148
+
149
+ table.reloadRowsAtIndexPaths([NSIndexPath(forRow: 0, inSection: num)], withRowAnimation: .Automatic)
150
+
151
+ }
152
+
153
+ else{
154
+
155
+ print(12345)
156
+
157
+ }
158
+
159
+ }
160
+
161
+ }
162
+
163
+
164
+
165
+ ```