質問編集履歴
16
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -424,8 +424,6 @@
|
|
424
424
|
|
425
425
|
CollectionViewCell①内にはUIImageView(ガンディー)のみ作成。
|
426
426
|
|
427
|
-
sizeForItemAt indexPath: は return CGSize(width: 100, height: frame.height - 540)です。
|
428
|
-
|
429
427
|
|
430
428
|
|
431
429
|
|
15
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -424,6 +424,8 @@
|
|
424
424
|
|
425
425
|
CollectionViewCell①内にはUIImageView(ガンディー)のみ作成。
|
426
426
|
|
427
|
+
sizeForItemAt indexPath: は return CGSize(width: 100, height: frame.height - 540)です。
|
428
|
+
|
427
429
|
|
428
430
|
|
429
431
|
|
14
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -428,4 +428,4 @@
|
|
428
428
|
|
429
429
|
|
430
430
|
|
431
|
-
画像の
|
431
|
+
画像の通り(目が光っているやつ)が後ろに回り込んでしまったりと、混ざってしまいます。
|
13
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -412,7 +412,7 @@
|
|
412
412
|
|
413
413
|
numberOfItemsInSectionのreturnは1です。
|
414
414
|
|
415
|
-
CollectionViewCell②内にはUIImageView(
|
415
|
+
CollectionViewCell②内にはUIImageView(目が光っているやつ)のみ作成。
|
416
416
|
|
417
417
|
|
418
418
|
|
12
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -399,3 +399,33 @@
|
|
399
399
|
|
400
400
|
|
401
401
|
よろしくお願いします。
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
//追記
|
408
|
+
|
409
|
+
![イメージ説明](3016c52de5244c0a66ff16c15acbe504.png)
|
410
|
+
|
411
|
+
CollectionView②(グリーン)の上にCollectionViewCell②(オレンジ)が乗っています。
|
412
|
+
|
413
|
+
numberOfItemsInSectionのreturnは1です。
|
414
|
+
|
415
|
+
CollectionViewCell②内にはUIImageView(フクロウ)のみ作成。
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
CollectionView①(レッド)の上にCollectionViewCell①(イエロー)が乗っています。
|
422
|
+
|
423
|
+
numberOfItemsInSectionのreturnは3です。
|
424
|
+
|
425
|
+
CollectionViewCell①内にはUIImageView(ガンディー)のみ作成。
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
画像のように混ざってしまいます。
|
11
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -386,7 +386,7 @@
|
|
386
386
|
|
387
387
|
現在、エラー
|
388
388
|
|
389
|
-
'could not dequeue a view of kind: UICollectionElementKindCell with identifier
|
389
|
+
'could not dequeue a view of kind: UICollectionElementKindCell with identifier cellBId - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' が発生します。
|
390
390
|
|
391
391
|
|
392
392
|
|
10
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,12 +78,208 @@
|
|
78
78
|
|
79
79
|
|
80
80
|
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
```ここに言語を入力
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
//下記コード
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
//UICollectionViewCell "hoge"内
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
...
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
110
|
+
|
111
|
+
return 30
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! Cell
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
136
|
+
|
137
|
+
return CGSize(width: 200, height: frame.height - 10)
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
...
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
上記のように、
|
160
|
+
|
161
|
+
UICollectionViewCell "hoge"内にUICollectionView①を作り、
|
162
|
+
|
163
|
+
クラスUICollectionViewCell①をregisterしています。
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
シミュレーターで見ると、UICollectionView①の上にUICollectionViewCell①が乗っているような形になっています。
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
81
173
|
---
|
82
174
|
|
83
175
|
|
84
176
|
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
今回行いたいのは、
|
186
|
+
|
187
|
+
UICollectionViewCell "hoge"内に
|
188
|
+
|
189
|
+
UICollectionView②を作り、
|
190
|
+
|
191
|
+
UICollectionViewCell②をregisterして
|
192
|
+
|
193
|
+
それをswitchで使い分けたいと考えています。
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
---
|
198
|
+
|
199
|
+
・クラスUICollectionViewCell "hoge" {
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
private let cellId = "cellId"
|
204
|
+
|
205
|
+
var cellBId = "cellId"
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
UICollectionView①作成
|
210
|
+
|
211
|
+
UICollectionView②作成
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
func {
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
UICollectionView①をaddsubView,constraintsなど
|
220
|
+
|
221
|
+
UICollectionView②をaddsubView,constraintsなど
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
クラスUICollectionViewCell①をレジスター
|
226
|
+
|
227
|
+
クラスUICollectionViewCell②をレジスター
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
//下記コード がここに入ります
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
・クラスUICollectionViewCell① {
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
func {
|
248
|
+
|
249
|
+
addsubView,constraintsなど
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
・クラスUICollectionViewCell② {
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
func {
|
264
|
+
|
265
|
+
addsubView,constraintsなど
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
---
|
276
|
+
|
277
|
+
|
278
|
+
|
85
279
|
```ここに言語を入力
|
86
280
|
|
281
|
+
```ここに言語を入力
|
282
|
+
|
87
283
|
|
88
284
|
|
89
285
|
//下記コード
|
@@ -106,6 +302,8 @@
|
|
106
302
|
|
107
303
|
|
108
304
|
|
305
|
+
|
306
|
+
|
109
307
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
110
308
|
|
111
309
|
return 30
|
@@ -116,10 +314,26 @@
|
|
116
314
|
|
117
315
|
|
118
316
|
|
317
|
+
//スイッチ
|
318
|
+
|
119
319
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
120
320
|
|
121
321
|
|
122
322
|
|
323
|
+
switch indexPath.item {
|
324
|
+
|
325
|
+
//UICollectionViewCell②の場合
|
326
|
+
|
327
|
+
case 1:
|
328
|
+
|
329
|
+
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellBId", for: indexPath) as! CellB
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
default:
|
336
|
+
|
123
337
|
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! Cell
|
124
338
|
|
125
339
|
}
|
@@ -132,6 +346,8 @@
|
|
132
346
|
|
133
347
|
|
134
348
|
|
349
|
+
|
350
|
+
|
135
351
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
136
352
|
|
137
353
|
return CGSize(width: 200, height: frame.height - 10)
|
@@ -154,22 +370,6 @@
|
|
154
370
|
|
155
371
|
|
156
372
|
|
157
|
-
|
158
|
-
|
159
|
-
上記のように、
|
160
|
-
|
161
|
-
UICollectionViewCell "hoge"内にUICollectionView①を作り、
|
162
|
-
|
163
|
-
クラスUICollectionViewCell①をregisterしています。
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
シミュレーターで見ると、UICollectionView①の上にUICollectionViewCell①が乗っているような形になっています。
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
373
|
---
|
174
374
|
|
175
375
|
|
@@ -178,206 +378,6 @@
|
|
178
378
|
|
179
379
|
|
180
380
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
今回行いたいのは、
|
186
|
-
|
187
|
-
UICollectionViewCell "hoge"内に
|
188
|
-
|
189
|
-
UICollectionView②を作り、
|
190
|
-
|
191
|
-
UICollectionViewCell②をregisterして
|
192
|
-
|
193
|
-
それをswitchで使い分けたいと考えています。
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
---
|
198
|
-
|
199
|
-
・クラスUICollectionViewCell "hoge" {
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
private let cellId = "cellId"
|
204
|
-
|
205
|
-
var cellBId = "cellId"
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
UICollectionView①作成
|
210
|
-
|
211
|
-
UICollectionView②作成
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
func {
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
UICollectionView①をaddsubView,constraintsなど
|
220
|
-
|
221
|
-
UICollectionView②をaddsubView,constraintsなど
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
クラスUICollectionViewCell①をレジスター
|
226
|
-
|
227
|
-
クラスUICollectionViewCell②をレジスター
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
//下記コード がここに入ります
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
}
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
・クラスUICollectionViewCell① {
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
func {
|
248
|
-
|
249
|
-
addsubView,constraintsなど
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
・クラスUICollectionViewCell② {
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
func {
|
264
|
-
|
265
|
-
addsubView,constraintsなど
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
}
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
---
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
```ここに言語を入力
|
280
|
-
|
281
|
-
```ここに言語を入力
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
//下記コード
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
//UICollectionViewCell "hoge"内
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
...
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
308
|
-
|
309
|
-
return 30
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
//スイッチ
|
318
|
-
|
319
|
-
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
switch indexPath.item {
|
324
|
-
|
325
|
-
//UICollectionViewCell②の場合
|
326
|
-
|
327
|
-
case 1:
|
328
|
-
|
329
|
-
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellBId", for: indexPath) as! CellB
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
default:
|
336
|
-
|
337
|
-
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! Cell
|
338
|
-
|
339
|
-
}
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
}
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
352
|
-
|
353
|
-
return CGSize(width: 200, height: frame.height - 10)
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
...
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
```
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
---
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
381
|
UICollectionViewCell②はdequeueのみ行いたいので、その他(numberOfItemsInSectionやsizeForItemAt indexPath)は行いたくありません。
|
382
382
|
|
383
383
|
|
9
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -190,7 +190,7 @@
|
|
190
190
|
|
191
191
|
UICollectionViewCell②をregisterして
|
192
192
|
|
193
|
-
それをswitch
|
193
|
+
それをswitchで使い分けたいと考えています。
|
194
194
|
|
195
195
|
|
196
196
|
|
8
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,8 +26,6 @@
|
|
26
26
|
|
27
27
|
private let cellId = "cellId"
|
28
28
|
|
29
|
-
var cellBId = "cellId"
|
30
|
-
|
31
29
|
|
32
30
|
|
33
31
|
UICollectionView①作成
|
@@ -196,7 +194,85 @@
|
|
196
194
|
|
197
195
|
|
198
196
|
|
199
|
-
|
197
|
+
---
|
198
|
+
|
199
|
+
・クラスUICollectionViewCell "hoge" {
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
private let cellId = "cellId"
|
204
|
+
|
205
|
+
var cellBId = "cellId"
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
UICollectionView①作成
|
210
|
+
|
211
|
+
UICollectionView②作成
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
func {
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
UICollectionView①をaddsubView,constraintsなど
|
220
|
+
|
221
|
+
UICollectionView②をaddsubView,constraintsなど
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
クラスUICollectionViewCell①をレジスター
|
226
|
+
|
227
|
+
クラスUICollectionViewCell②をレジスター
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
//下記コード がここに入ります
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
・クラスUICollectionViewCell① {
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
func {
|
248
|
+
|
249
|
+
addsubView,constraintsなど
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
・クラスUICollectionViewCell② {
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
func {
|
264
|
+
|
265
|
+
addsubView,constraintsなど
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
---
|
200
276
|
|
201
277
|
|
202
278
|
|
7
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
private let cellId = "cellId"
|
28
28
|
|
29
|
-
var
|
29
|
+
var cellBId = "cellId"
|
30
30
|
|
31
31
|
|
32
32
|
|
6
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,12 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
private let cellId = "cellId"
|
28
|
+
|
29
|
+
var bcellId = "cellId"
|
30
|
+
|
31
|
+
|
32
|
+
|
27
33
|
UICollectionView①作成
|
28
34
|
|
29
35
|
|
5
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -160,6 +160,8 @@
|
|
160
160
|
|
161
161
|
|
162
162
|
|
163
|
+
シミュレーターで見ると、UICollectionView①の上にUICollectionViewCell①が乗っているような形になっています。
|
164
|
+
|
163
165
|
|
164
166
|
|
165
167
|
|
4
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,27 +2,149 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
5
|
-
|
15
|
+
現在のコードは簡単に表現すると、このような形になっています。
|
6
|
-
|
16
|
+
|
17
|
+
|
18
|
+
|
7
|
-
|
19
|
+
---
|
8
|
-
|
9
|
-
|
10
|
-
|
20
|
+
|
21
|
+
|
22
|
+
|
11
|
-
UICollectionViewCell "hoge"{
|
23
|
+
・クラスUICollectionViewCell "hoge" {
|
12
|
-
|
13
|
-
|
14
|
-
|
24
|
+
|
25
|
+
|
26
|
+
|
15
|
-
UICollectionView①
|
27
|
+
UICollectionView①作成
|
28
|
+
|
29
|
+
|
30
|
+
|
16
|
-
|
31
|
+
func {
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
UICollectionView①をaddsubView,constraintsなど
|
36
|
+
|
37
|
+
|
38
|
+
|
17
|
-
UICollectionViewCell①
|
39
|
+
クラスUICollectionViewCell①をレジスター
|
40
|
+
|
41
|
+
|
18
42
|
|
19
43
|
}
|
20
44
|
|
21
45
|
|
22
46
|
|
47
|
+
|
48
|
+
|
49
|
+
//下記コード がここに入ります
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
23
|
-
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
24
|
-
|
59
|
+
・クラスUICollectionViewCell① {
|
60
|
+
|
61
|
+
|
62
|
+
|
25
|
-
|
63
|
+
func {
|
64
|
+
|
65
|
+
addsubView,constraintsなど
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
```ここに言語を入力
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
//下記コード
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
//UICollectionViewCell "hoge"内
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
...
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
106
|
+
|
107
|
+
return 30
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! Cell
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
132
|
+
|
133
|
+
return CGSize(width: 200, height: frame.height - 10)
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
...
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
```
|
26
148
|
|
27
149
|
|
28
150
|
|
@@ -34,11 +156,11 @@
|
|
34
156
|
|
35
157
|
UICollectionViewCell "hoge"内にUICollectionView①を作り、
|
36
158
|
|
37
|
-
そのUICollectionView①の上にregisterしたUICollectionViewCell①の乗せる形を取っています。
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
159
|
+
クラスUICollectionViewCell①をregisterしています。
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
42
164
|
|
43
165
|
|
44
166
|
|
@@ -54,43 +176,113 @@
|
|
54
176
|
|
55
177
|
|
56
178
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
UICollectionView
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
179
|
+
今回行いたいのは、
|
180
|
+
|
181
|
+
UICollectionViewCell "hoge"内に
|
182
|
+
|
183
|
+
UICollectionView②を作り、
|
184
|
+
|
185
|
+
UICollectionViewCell②をregisterして
|
186
|
+
|
187
|
+
それをswitchを使い分けたいと考えています。
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
```ここに言語を入力
|
196
|
+
|
197
|
+
```ここに言語を入力
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
//下記コード
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
//UICollectionViewCell "hoge"内
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
...
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
224
|
+
|
225
|
+
return 30
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
//スイッチ
|
234
|
+
|
235
|
+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
switch indexPath.item {
|
240
|
+
|
241
|
+
//UICollectionViewCell②の場合
|
242
|
+
|
243
|
+
case 1:
|
244
|
+
|
245
|
+
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellBId", for: indexPath) as! CellB
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
default:
|
252
|
+
|
253
|
+
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! Cell
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
268
|
+
|
269
|
+
return CGSize(width: 200, height: frame.height - 10)
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
...
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
```
|
284
|
+
|
285
|
+
|
94
286
|
|
95
287
|
|
96
288
|
|
@@ -98,11 +290,17 @@
|
|
98
290
|
|
99
291
|
|
100
292
|
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
101
|
-
|
297
|
+
UICollectionViewCell②はdequeueのみ行いたいので、その他(numberOfItemsInSectionやsizeForItemAt indexPath)は行いたくありません。
|
102
|
-
|
103
|
-
|
104
|
-
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
105
|
-
エラー
|
303
|
+
現在、エラー
|
106
304
|
|
107
305
|
'could not dequeue a view of kind: UICollectionElementKindCell with identifier bcellId - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' が発生します。
|
108
306
|
|
@@ -112,97 +310,7 @@
|
|
112
310
|
|
113
311
|
|
114
312
|
|
115
|
-
```ここに言語を入力
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
//UICollectionViewCell "hoge"内です
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
...省略してます
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
//default構造 の場合
|
138
|
-
|
139
|
-
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
140
|
-
|
141
|
-
return 30
|
142
|
-
|
143
|
-
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
//スイッチ
|
150
|
-
|
151
|
-
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
switch indexPath.item {
|
156
|
-
|
157
|
-
//ケース1 の場合
|
158
|
-
|
159
|
-
case 1:
|
160
|
-
|
161
|
-
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellBId", for: indexPath) as! CellB
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
//default構造 の場合
|
166
|
-
|
167
|
-
default:
|
168
|
-
|
169
|
-
return collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! Cell
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
}
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
//default構造 の場合
|
182
|
-
|
183
|
-
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
184
|
-
|
185
|
-
return CGSize(width: 200, height: frame.height - 10)
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
...省略してます
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
```
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
正しいswitch文で
|
313
|
+
正しいswitch文で、それぞれdequeueすることが可能でしたらご指摘いただきたいです。
|
204
|
-
|
205
|
-
ご指摘いただければ助かります。
|
206
314
|
|
207
315
|
|
208
316
|
|
3
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -200,7 +200,7 @@
|
|
200
200
|
|
201
201
|
|
202
202
|
|
203
|
-
正しいswitch文で
|
203
|
+
正しいswitch文で(default構造 + ケース1)をそれぞれdequeueすることが可能でしたら
|
204
204
|
|
205
205
|
ご指摘いただければ助かります。
|
206
206
|
|
2
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
いつもお世話になっています。
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
(default構造)
|
2
6
|
|
3
7
|
下
|
1
変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
collectionViewCell switch
|
1
|
+
collectionViewCell switch文でdequeueしたいです。
|
test
CHANGED
File without changes
|