質問編集履歴
3
実行箇所の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
```
|
82
82
|
|
83
|
-
▼Label側
|
83
|
+
▼Label側(Viewの中にLabelを配置) Labelはstoryboard上でLines=0としております
|
84
84
|
|
85
85
|
// View include Label
|
86
86
|
|
@@ -154,6 +154,50 @@
|
|
154
154
|
|
155
155
|
|
156
156
|
|
157
|
+
▼実行箇所
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
162
|
+
|
163
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! sampleTableViewCell
|
164
|
+
|
165
|
+
cell.labelName.text = "1234567890"
|
166
|
+
|
167
|
+
★ここでLabel側の制約処理を実行しています
|
168
|
+
|
169
|
+
return cell
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
176
|
+
|
177
|
+
sampleTableView.estimatedRowHeight = 150
|
178
|
+
|
179
|
+
return UITableViewAutomaticDimension
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
|
186
|
+
|
187
|
+
tableView.beginUpdates()
|
188
|
+
|
189
|
+
★ここでTextView側の制約処理を実行しています
|
190
|
+
|
191
|
+
tableView.estimatedRowHeight = 150
|
192
|
+
|
193
|
+
tableView.rowHeight = UITableViewAutomaticDimension
|
194
|
+
|
195
|
+
tableView.endUpdates()
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
157
201
|
```
|
158
202
|
|
159
203
|
|
2
誤記の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -142,13 +142,13 @@
|
|
142
142
|
|
143
143
|
NSLayoutConstraint.activate([
|
144
144
|
|
145
|
-
textView.topAnchor.constraint(equalTo:
|
145
|
+
textView.topAnchor.constraint(equalTo: textBaseView.topAnchor),
|
146
146
|
|
147
|
-
textView.bottomAnchor.constraint(equalTo:
|
147
|
+
textView.bottomAnchor.constraint(equalTo: textBaseView.bottomAnchor),
|
148
148
|
|
149
|
-
textView.leadingAnchor.constraint(equalTo:
|
149
|
+
textView.leadingAnchor.constraint(equalTo: textBaseView.leadingAnchor),
|
150
150
|
|
151
|
-
textView.trailingAnchor.constraint(equalTo:
|
151
|
+
textView.trailingAnchor.constraint(equalTo: textBaseView.trailingAnchor)
|
152
152
|
|
153
153
|
])
|
154
154
|
|
1
該当のソースコードに制約のコードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,6 +78,84 @@
|
|
78
78
|
|
79
79
|
### 該当のソースコード
|
80
80
|
|
81
|
+
```
|
82
|
+
|
83
|
+
▼Label側(Viewの中にLabelを配置) Labelはstoryboard上でLines=0としております
|
84
|
+
|
85
|
+
// View include Label
|
86
|
+
|
87
|
+
labelBaseView.translatesAutoresizingMaskIntoConstraints = false
|
88
|
+
|
89
|
+
NSLayoutConstraint.activate([
|
90
|
+
|
91
|
+
labelBaseView.widthAnchor.constraint(equalToConstant: 400.0),
|
92
|
+
|
93
|
+
labelBaseView.topAnchor.constraint(equalTo: cell.topAnchor, constant: 5.0),
|
94
|
+
|
95
|
+
labelBaseView.leadingAnchor.constraint(equalTo: cell.leadingAnchor, constant: 10.0),
|
96
|
+
|
97
|
+
labelBaseView.bottomAnchor.constraint(equalTo: cell.bottomAnchor, constant: 0.0)
|
98
|
+
|
99
|
+
])
|
100
|
+
|
101
|
+
// Label
|
102
|
+
|
103
|
+
labelName.translatesAutoresizingMaskIntoConstraints = false
|
104
|
+
|
105
|
+
NSLayoutConstraint.activate([
|
106
|
+
|
107
|
+
labelName.topAnchor.constraint(equalTo: labelBaseView.topAnchor, constant: 0.0),
|
108
|
+
|
109
|
+
labelName.leadingAnchor.constraint(equalTo: labelBaseView.leadingAnchor, constant: 0.0),
|
110
|
+
|
111
|
+
labelName.trailingAnchor.constraint(equalTo: labelBaseView.trailingAnchor, constant: 0.0),
|
112
|
+
|
113
|
+
labelName.bottomAnchor.constraint(equalTo: labelBaseView.bottomAnchor, constant: 0.0)
|
114
|
+
|
115
|
+
])
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
▼TextView側(Viewの中にTextViewを配置)
|
120
|
+
|
121
|
+
// View include TextView
|
122
|
+
|
123
|
+
textBaseView.translatesAutoresizingMaskIntoConstraints = false
|
124
|
+
|
125
|
+
textBaseView.heightAnchor.constraint(equalToConstant: 300.0).isActive = true
|
126
|
+
|
127
|
+
textBaseView.topAnchor.constraint(equalTo: cell.topAnchor, constant: 10.0).isActive = true
|
128
|
+
|
129
|
+
textBaseView.leadingAnchor.constraint(equalTo: labelBaseView.trailingAnchor, constant: 8.0).isActive = true
|
130
|
+
|
131
|
+
textBaseView.trailingAnchor.constraint(equalTo: cell.trailingAnchor, constant: -10.0).isActive = true
|
132
|
+
|
133
|
+
if labelHeight < 300.0 {
|
134
|
+
|
135
|
+
inputBaseView.bottomAnchor.constraint(equalTo: cell.bottomAnchor, constant: -10.0).isActive = true
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
// TextView
|
140
|
+
|
141
|
+
textView.translatesAutoresizingMaskIntoConstraints = false
|
142
|
+
|
143
|
+
NSLayoutConstraint.activate([
|
144
|
+
|
145
|
+
textView.topAnchor.constraint(equalTo: inputBaseView.topAnchor),
|
146
|
+
|
147
|
+
textView.bottomAnchor.constraint(equalTo: inputBaseView.bottomAnchor),
|
148
|
+
|
149
|
+
textView.leadingAnchor.constraint(equalTo: inputBaseView.leadingAnchor),
|
150
|
+
|
151
|
+
textView.trailingAnchor.constraint(equalTo: inputBaseView.trailingAnchor)
|
152
|
+
|
153
|
+
])
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
```
|
158
|
+
|
81
159
|
|
82
160
|
|
83
161
|
### 試したこと
|