質問編集履歴
5
Viewの展開
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,13 +7,11 @@
|
|
7
7
|
前述したContainerViewの中にCollectionViewを置いても内容が表示されません....。解決方法待ってます!
|
8
8
|
|
9
9
|

|
10
|
-
|
11
10
|

|
11
|
+

|
12
|
+

|
12
13
|
|
13
|
-

|
14
14
|
|
15
|
-

|
16
|
-
|
17
15
|
```swift
|
18
16
|
import UIKit
|
19
17
|
|
4
もう1つ
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
|
13
13
|

|
14
14
|
|
15
|
+

|
16
|
+
|
15
17
|
```swift
|
16
18
|
import UIKit
|
17
19
|
|
3
StoryBoard追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
11
|

|
12
12
|
|
13
|
+

|
14
|
+
|
13
15
|
```swift
|
14
16
|
import UIKit
|
15
17
|
|
2
コード追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,4 +8,44 @@
|
|
8
8
|
|
9
9
|

|
10
10
|
|
11
|
-

|
11
|
+

|
12
|
+
|
13
|
+
```swift
|
14
|
+
import UIKit
|
15
|
+
|
16
|
+
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
|
17
|
+
|
18
|
+
let photos = ["mana1", "mana2","mana3"]
|
19
|
+
|
20
|
+
override func viewDidLoad() {
|
21
|
+
super.viewDidLoad()
|
22
|
+
// Do any additional setup after loading the view, typically from a nib.
|
23
|
+
}
|
24
|
+
|
25
|
+
func numberOfSections(in collectionView: UICollectionView) -> Int {
|
26
|
+
// #warning Incomplete implementation, return the number of sections
|
27
|
+
return 1
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
32
|
+
// #warning Incomplete implementation, return the number of items
|
33
|
+
return 3
|
34
|
+
}
|
35
|
+
|
36
|
+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
37
|
+
// Cell はストーリーボードで設定したセルのID
|
38
|
+
let testCell:UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath)
|
39
|
+
|
40
|
+
// Tag番号を使ってImageViewのインスタンス生成
|
41
|
+
let imageView = testCell.contentView.viewWithTag(1) as! UIImageView
|
42
|
+
// 画像配列の番号で指定された要素の名前の画像をUIImageとする
|
43
|
+
let cellImage = UIImage(named: photos[(indexPath as IndexPath).row])
|
44
|
+
// UIImageをUIImageViewのimageとして設定
|
45
|
+
imageView.image = cellImage
|
46
|
+
|
47
|
+
return testCell
|
48
|
+
}
|
49
|
+
|
50
|
+
}
|
51
|
+
```
|
1
コード追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,4 +6,6 @@
|
|
6
6
|
|
7
7
|
前述したContainerViewの中にCollectionViewを置いても内容が表示されません....。解決方法待ってます!
|
8
8
|
|
9
|
-

|
9
|
+

|
10
|
+
|
11
|
+

|