質問編集履歴

3

2020/08/15 03:25

投稿

kazuki_user
kazuki_user

スコア147

test CHANGED
File without changes
test CHANGED
@@ -66,7 +66,11 @@
66
66
 
67
67
 
68
68
 
69
- ## 参考サイ
69
+ ## スクリーンショッ
70
+
71
+
72
+
73
+ ![イメージ説明](2ceaa6d9fa0e8599434823d859ce731b.png)
70
74
 
71
75
 
72
76
 

2

2020/08/15 03:25

投稿

kazuki_user
kazuki_user

スコア147

test CHANGED
@@ -1 +1 @@
1
- GridViewが効かない【iOS】
1
+ GridViewの幅埋まらない【iOS】
test CHANGED
@@ -1,10 +1,8 @@
1
- ## GridViewが効かない
1
+ ## GridViewの幅埋まらない
2
2
 
3
3
 
4
4
 
5
- Width, Heightを共に150に設定したのですが、画像が拡大表示されてしまいます。
6
-
7
- 解決策を教えていただけると嬉しいです。
5
+ 解決策を教えてけると嬉しいです。????
8
6
 
9
7
 
10
8
 
@@ -12,9 +10,13 @@
12
10
 
13
11
 
14
12
 
15
- ```
13
+ 実行不可になるエラーではないですが、RUNした時に下記が表示されます。
16
14
 
15
+
16
+
17
+ ```error
18
+
17
- 2020-08-15 12:03:58.738401+0900 GoodEatIns[49944:4744098] [LayoutConstraints] Unable to simultaneously satisfy constraints.
19
+ [LayoutConstraints] Unable to simultaneously satisfy constraints.
18
20
 
19
21
  Probably at least one of the constraints in the following list is one you don't want.
20
22
 
@@ -24,113 +26,15 @@
24
26
 
25
27
  (2) find the code that added the unwanted constraint or constraints and fix it.
26
28
 
27
- ```
29
+ (
28
30
 
31
+ "<NSLayoutConstraint:0x600000bf0eb0 V:|-(0)-[UIImageView:0x7faff2507c10] (active, names: '|':UITableViewCellContentView:0x7faff250a270 )>",
29
32
 
33
+ "<NSLayoutConstraint:0x600000bf0ff0 UIImageView:0x7faff2507c10.top == UITableViewCellContentView:0x7faff250a270.topMargin (active)>",
30
34
 
31
- ## コード
35
+ "<NSLayoutConstraint:0x600000bf1630 'UIView-topMargin-guide-constraint' V:|-(11)-[UILayoutGuide:0x6000011a1dc0'UIViewLayoutMarginsGuide'] (active, names: '|':UITableViewCellContentView:0x7faff250a270 )>"
32
36
 
33
-
34
-
35
- ```RecipeView
36
-
37
- import UIKit
38
-
39
-
40
-
41
- class RecipeCell: UICollectionViewCell {
42
-
43
-
44
-
45
- @IBOutlet weak var recipeImg: UIImageView!
46
-
47
-
48
-
49
- override func awakeFromNib() {
50
-
51
- super.awakeFromNib()
52
-
53
- recipeImg.layer.cornerRadius = 10
54
-
55
- }
37
+ )
56
-
57
-
58
-
59
- func configureCell(recipe: Recipe) {
60
-
61
- recipeImg.image = UIImage(named: recipe.imageName)
62
-
63
- }
64
-
65
- }
66
-
67
- ```
68
-
69
-
70
-
71
- ```RecipeVC
72
-
73
- import UIKit
74
-
75
-
76
-
77
- class RecipesSelectionVC: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
78
-
79
-
80
-
81
- var selectedCategory : String!
82
-
83
- var recipes : [Recipe]!
84
-
85
- var data = DataSet()
86
-
87
-
88
-
89
-
90
-
91
- @IBOutlet weak var CollectionView: UICollectionView!
92
-
93
-
94
-
95
- override func viewDidLoad() {
96
-
97
- super.viewDidLoad()
98
-
99
- CollectionView.delegate = self
100
-
101
- CollectionView.dataSource = self
102
-
103
- recipes = data.getRecipes(forCategoryTitle: selectedCategory)
104
-
105
- }
106
-
107
-
108
-
109
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
110
-
111
- return recipes.count
112
-
113
- }
114
-
115
-
116
-
117
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
118
-
119
- if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "recipeCell", for: indexPath) as? RecipeCell {
120
-
121
- let recipe = recipes[indexPath.item]
122
-
123
- cell.configureCell(recipe: recipe)
124
-
125
- return cell
126
-
127
- }
128
-
129
- return UICollectionViewCell()
130
-
131
- }
132
-
133
- }
134
38
 
135
39
 
136
40
 
@@ -138,7 +42,33 @@
138
42
 
139
43
 
140
44
 
45
+
46
+
47
+
48
+
49
+ ## やってみた事など
50
+
51
+
52
+
53
+ ```recipeVC
54
+
55
+ func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
56
+
57
+ let width = view.bounds.width
58
+
59
+ let cellDimension = (width / 2) - 15
60
+
141
- ![![イメージ説明](22e775424096965cec8f6659f7fca2f3.png)](a8399994b693190bf198b3872a4b88b4.png)
61
+ return CGSize(width: cellDimension, height: cellDimension)
62
+
63
+ }
64
+
65
+ ```
66
+
67
+
68
+
69
+ ## 参考サイト
70
+
71
+
142
72
 
143
73
 
144
74
 

1

2020/08/15 03:24

投稿

kazuki_user
kazuki_user

スコア147

test CHANGED
File without changes
test CHANGED
@@ -9,6 +9,26 @@
9
9
 
10
10
 
11
11
  ## エラー
12
+
13
+
14
+
15
+ ```
16
+
17
+ 2020-08-15 12:03:58.738401+0900 GoodEatIns[49944:4744098] [LayoutConstraints] Unable to simultaneously satisfy constraints.
18
+
19
+ Probably at least one of the constraints in the following list is one you don't want.
20
+
21
+ Try this:
22
+
23
+ (1) look at each constraint and try to figure out which you don't expect;
24
+
25
+ (2) find the code that added the unwanted constraint or constraints and fix it.
26
+
27
+ ```
28
+
29
+
30
+
31
+ ## コード
12
32
 
13
33
 
14
34