teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

諸々

2018/10/04 05:11

投稿

nekokichi
nekokichi

スコア54

title CHANGED
File without changes
body CHANGED
@@ -71,18 +71,15 @@
71
71
 
72
72
 
73
73
  ※追記
74
- 上に載せていたViewを削除して、ContentViewに対して
75
74
  ```Swift
76
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
75
+ func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
77
-
78
- //gurad文でカスタムセルを読み込み、無理ならUITableViewCell()を返す
79
- guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? TableViewCell else { return UITableViewCell() }
76
+ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
80
-
77
+ let viewController = UIViewController()
78
+ viewController.view.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
81
- // cell.backgroundColor = dataSource[indexPath.row]
79
+ // viewController.view.backgroundColor = dataSource[indexPath.row]
82
80
  cell.contentView.backgroundColor = dataSource[indexPath.row]
83
-
81
+ cell.addSubview(viewController.view)
84
82
  return cell
85
-
86
83
  }
87
84
  ```
88
85
  と書きましたが、変わりませんでした。

1

諸々

2018/10/04 05:11

投稿

nekokichi
nekokichi

スコア54

title CHANGED
File without changes
body CHANGED
@@ -66,4 +66,23 @@
66
66
  ```
67
67
  ![イメージ説明](f541dec8fce8f789b5b363b882e550a0.png)
68
68
 
69
- ![イメージ説明](c4cd65b60b87c1979f264c91fff597ff.png)
69
+ ![イメージ説明](c4cd65b60b87c1979f264c91fff597ff.png)
70
+
71
+
72
+
73
+ ※追記
74
+ 上に載せていたViewを削除して、ContentViewに対して
75
+ ```Swift
76
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
77
+
78
+ //gurad文でカスタムセルを読み込み、無理ならUITableViewCell()を返す
79
+ guard let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? TableViewCell else { return UITableViewCell() }
80
+
81
+ // cell.backgroundColor = dataSource[indexPath.row]
82
+ cell.contentView.backgroundColor = dataSource[indexPath.row]
83
+
84
+ return cell
85
+
86
+ }
87
+ ```
88
+ と書きましたが、変わりませんでした。