質問編集履歴
1
カスタムセルの記述が違いました
title
CHANGED
File without changes
|
body
CHANGED
@@ -70,7 +70,7 @@
|
|
70
70
|
Cellの総数を返す
|
71
71
|
*/
|
72
72
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
73
|
-
return
|
73
|
+
return 8
|
74
74
|
}
|
75
75
|
|
76
76
|
/*
|
@@ -79,7 +79,6 @@
|
|
79
79
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
80
80
|
|
81
81
|
let cell : CustomUICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "MyCell", for: indexPath) as! CustomUICollectionViewCell
|
82
|
-
cell.textLabel?.text = indexPath.row.description
|
83
82
|
|
84
83
|
return cell
|
85
84
|
}
|
@@ -94,7 +93,7 @@
|
|
94
93
|
|
95
94
|
class CustomUICollectionViewCell : UICollectionViewCell{
|
96
95
|
|
97
|
-
var
|
96
|
+
var imageView: UIImageView!
|
98
97
|
|
99
98
|
required init(coder aDecoder: NSCoder) {
|
100
99
|
super.init(coder: aDecoder)!
|
@@ -104,13 +103,11 @@
|
|
104
103
|
super.init(frame: frame)
|
105
104
|
|
106
105
|
// UILabelを生成.
|
107
|
-
|
106
|
+
imageView = UIImageView(frame: CGRect(x:0, y:0, width:frame.width, height:frame.height))
|
108
|
-
textLabel?.text = "nil"
|
109
|
-
|
107
|
+
imageView.backgroundColor = UIColor.white
|
110
|
-
textLabel?.textAlignment = NSTextAlignment.center
|
111
108
|
|
112
109
|
// Cellに追加.
|
113
|
-
self.contentView.addSubview(
|
110
|
+
self.contentView.addSubview(imageView)
|
114
111
|
}
|
115
112
|
|
116
113
|
}
|