0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

collectionviewでcellが一つしか表示されない問題

0
Posted at

そりゃそうなるか

って感じのミスだったのですが、同じことをうっかりやる人がいかねないのでここに記します。

cell.frameに値を手動で突っ込んだ

cell.frameはcollectionViewを親とするframe。
だから全てのcell.frameに一定の値を入れると、全部重なって一つしかcellが表示されていないように見えます
当たり前ですね。

cellのサイズと位置はcollectionViewのLayoutによって決めよう

cellのframeは直接指定するのではなく、それを持つcollectionViewのLayout機能に任せましょう
(なんならもとよりcollectionViewはcellのframeを計算する機能がメインだろアホか僕…)
Layoutに関しては下の記事が非常にわかりやすく汎用的に書いてくれていたのでこちらを読むのが良いでしょう。
https://techlife.cookpad.com/entry/2017/06/29/190000

以上現場からでした

(´-`).。oO(同じことする人いるのかなぁ

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?