質問編集履歴
2
code追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -246,8 +246,58 @@
|
|
246
246
|
|
247
247
|
viewheight.constant = totalheight
|
248
248
|
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
//他に関係がありそうな箇所
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
override func viewWillAppear(_ animated: Bool) {
|
260
|
+
|
261
|
+
super.viewWillAppear(true)
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
let userdefaults = UserDefaults.standard
|
266
|
+
|
267
|
+
userdefaults.register(defaults: ["characterSize":"17"])
|
268
|
+
|
269
|
+
if let cSize :Int = userdefaults.integer(forKey: "characterSize") as Int?{
|
270
|
+
|
271
|
+
let cgSize = CGFloat(cSize)
|
272
|
+
|
273
|
+
testtext.font = UIFont.boldSystemFont(ofSize: cgSize)
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
makeScroll()
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
}
|
282
|
+
|
249
283
|
|
250
284
|
|
285
|
+
|
286
|
+
|
287
|
+
override func viewDidLayoutSubviews() {
|
288
|
+
|
289
|
+
super.viewDidLayoutSubviews()
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
makeScroll()
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
251
301
|
```
|
252
302
|
|
253
303
|
|
1
画像が表示されてなかった
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
と
|
33
|
+
しかし、「ときどき」なのですが、画像のようにimageViewがtextviewに被ってしまうことがあります。
|
34
34
|
|
35
35
|
|
36
36
|
|
@@ -40,206 +40,216 @@
|
|
40
40
|
|
41
41
|
|
42
42
|
|
43
|
+
StoryBoard上での表示
|
44
|
+
|
45
|
+
![StoryBoard上での表示](7e0d74e31046b856c931ad9134a835dd.png)
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
直接開いた場合
|
52
|
+
|
53
|
+
![直線開いた時](f34b39ce7c8cb42381d7f25238fbee01.jpeg)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
ボタンで変更した時
|
60
|
+
|
61
|
+
![ボタンで変更した時](b41523ccee745f40b80d00ff1a90d43b.jpeg)
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
###該当のソースコード
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
```swift
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
//Viewに文章と画像を入れる
|
78
|
+
|
79
|
+
func setquestion() {
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
var imgCount: Int = 0
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
dataDetail = self.delegate.dataDetail
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
testtext.text = ""
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
questionNum = dataDetail[0] + dataDetail[1] + dataDetail[2]
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
dataPosition = String(self.delegate.indexRow + 1) + "/" + String(self.delegate.dataList.count)
|
100
|
+
|
101
|
+
label.title = questionNum + "-" + dataPosition + "問"
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
for i in 8...19 {
|
108
|
+
|
109
|
+
if dataDetail[i] != ""{
|
110
|
+
|
111
|
+
testtext.text = testtext.text + dataDetail[i] + "\n"
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
if i == 9{
|
116
|
+
|
117
|
+
testtext.text = testtext.text + "\n"
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
testtext.text = testtext.text.replacingOccurrences(of: " ", with: "\n ")
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
imgToatalHeight = 0
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
autoreleasepool{
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
for i in 0...4 {
|
138
|
+
|
139
|
+
if dataDetail[21 + i] != "" {
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
let filePath = dataDetail[0] + "/" + dataDetail[0] + dataDetail[1] + "/" + dataDetail[21 + i]
|
144
|
+
|
145
|
+
let imgPath = Bundle.main.path(forResource: filePath, ofType: "png")
|
146
|
+
|
147
|
+
let theImage = UIImage(contentsOfFile: imgPath!)
|
148
|
+
|
149
|
+
ratio = CGFloat((theImage?.size.height)! / (theImage?.size.width)!)
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
imgView[i].image = theImage
|
154
|
+
|
155
|
+
imgView[i].frame = CGRect(x: 0, y: 0, width: imgWidth, height: imgWidth * ratio)
|
156
|
+
|
157
|
+
imgCount += 1
|
158
|
+
|
159
|
+
}else{
|
160
|
+
|
161
|
+
imgView[i].image = nil
|
162
|
+
|
163
|
+
imgView[i].frame = CGRect(x: 0, y: 0, width: 0, height: 0)
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
imgHeight[i].constant = imgView[i].frame.height
|
170
|
+
|
171
|
+
imgToatalHeight = imgToatalHeight + imgView[i].frame.height
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
let imgSpace: Int = 8 * imgCount
|
182
|
+
|
183
|
+
imgToatalHeight = imgToatalHeight + CGFloat(imgSpace)
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
nextButton.setTitleColor(UIColor.black, for: .normal)
|
188
|
+
|
189
|
+
nextButton.layer.masksToBounds = true
|
190
|
+
|
191
|
+
nextButton.layer.cornerRadius = 10.0
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
if self.delegate.dataList.last != self.delegate.dataList[self.delegate.indexRow]{
|
196
|
+
|
197
|
+
nextButton.alpha = 1
|
198
|
+
|
199
|
+
}else{
|
200
|
+
|
201
|
+
nextButton.alpha = 0
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
myscroll.contentOffset = CGPoint(x: 0, y: -myscroll.contentInset.top)
|
208
|
+
|
209
|
+
if let nv = navigationController {
|
210
|
+
|
211
|
+
nv.setNavigationBarHidden(false, animated: false)
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
makeScroll()
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
//scrollViewのContentのHeightを決める
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
func makeScroll(){
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
testtext.sizeToFit()
|
236
|
+
|
237
|
+
textheight.constant = testtext.contentSize.height
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
let totalheight: CGFloat = testtext.contentSize.height + imgToatalHeight
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
myscroll.contentSize.height = totalheight
|
246
|
+
|
247
|
+
viewheight.constant = totalheight
|
248
|
+
|
249
|
+
|
250
|
+
|
43
251
|
```
|
44
252
|
|
45
|
-
![StoryBoard](d68a3f6238d93ac214e957e97fbcd01e.png)
|
46
|
-
|
47
|
-
![直線開いた時](f34b39ce7c8cb42381d7f25238fbee01.jpeg)
|
48
|
-
|
49
|
-
![ボタンで変更した時](b41523ccee745f40b80d00ff1a90d43b.jpeg)
|
50
|
-
|
51
|
-
```
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
###該当のソースコード
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
```swift
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
//Viewに文章と画像を入れる
|
68
|
-
|
69
|
-
func setquestion() {
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
var imgCount: Int = 0
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
dataDetail = self.delegate.dataDetail
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
testtext.text = ""
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
questionNum = dataDetail[0] + dataDetail[1] + dataDetail[2]
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
dataPosition = String(self.delegate.indexRow + 1) + "/" + String(self.delegate.dataList.count)
|
90
|
-
|
91
|
-
label.title = questionNum + "-" + dataPosition + "問"
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
for i in 8...19 {
|
98
|
-
|
99
|
-
if dataDetail[i] != ""{
|
100
|
-
|
101
|
-
testtext.text = testtext.text + dataDetail[i] + "\n"
|
102
|
-
|
103
|
-
}
|
104
|
-
|
105
|
-
if i == 9{
|
106
|
-
|
107
|
-
testtext.text = testtext.text + "\n"
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
testtext.text = testtext.text.replacingOccurrences(of: " ", with: "\n ")
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
imgToatalHeight = 0
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
autoreleasepool{
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
for i in 0...4 {
|
128
|
-
|
129
|
-
if dataDetail[21 + i] != "" {
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
let filePath = dataDetail[0] + "/" + dataDetail[0] + dataDetail[1] + "/" + dataDetail[21 + i]
|
134
|
-
|
135
|
-
let imgPath = Bundle.main.path(forResource: filePath, ofType: "png")
|
136
|
-
|
137
|
-
let theImage = UIImage(contentsOfFile: imgPath!)
|
138
|
-
|
139
|
-
ratio = CGFloat((theImage?.size.height)! / (theImage?.size.width)!)
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
imgView[i].image = theImage
|
144
|
-
|
145
|
-
imgView[i].frame = CGRect(x: 0, y: 0, width: imgWidth, height: imgWidth * ratio)
|
146
|
-
|
147
|
-
imgCount += 1
|
148
|
-
|
149
|
-
}else{
|
150
|
-
|
151
|
-
imgView[i].image = nil
|
152
|
-
|
153
|
-
imgView[i].frame = CGRect(x: 0, y: 0, width: 0, height: 0)
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
imgHeight[i].constant = imgView[i].frame.height
|
160
|
-
|
161
|
-
imgToatalHeight = imgToatalHeight + imgView[i].frame.height
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
let imgSpace: Int = 8 * imgCount
|
172
|
-
|
173
|
-
imgToatalHeight = imgToatalHeight + CGFloat(imgSpace)
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
nextButton.setTitleColor(UIColor.black, for: .normal)
|
178
|
-
|
179
|
-
nextButton.layer.masksToBounds = true
|
180
|
-
|
181
|
-
nextButton.layer.cornerRadius = 10.0
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
if self.delegate.dataList.last != self.delegate.dataList[self.delegate.indexRow]{
|
186
|
-
|
187
|
-
nextButton.alpha = 1
|
188
|
-
|
189
|
-
}else{
|
190
|
-
|
191
|
-
nextButton.alpha = 0
|
192
|
-
|
193
|
-
}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
myscroll.contentOffset = CGPoint(x: 0, y: -myscroll.contentInset.top)
|
198
|
-
|
199
|
-
if let nv = navigationController {
|
200
|
-
|
201
|
-
nv.setNavigationBarHidden(false, animated: false)
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
makeScroll()
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
//scrollViewのContentのHeightを決める
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
func makeScroll(){
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
testtext.sizeToFit()
|
226
|
-
|
227
|
-
textheight.constant = testtext.contentSize.height
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
let totalheight: CGFloat = testtext.contentSize.height + imgToatalHeight
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
myscroll.contentSize.height = totalheight
|
236
|
-
|
237
|
-
viewheight.constant = totalheight
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
```
|
242
|
-
|
243
253
|
|
244
254
|
|
245
255
|
###試したこと
|