質問編集履歴
1
ファイル名変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
csvファイルの画像が表示されません
|
test
CHANGED
@@ -1,19 +1,11 @@
|
|
1
|
-
### 前提・実現したいこと
|
1
|
+
**ボールドテキスト**### 前提・実現したいこと
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
csvファイルから画像を引っ張ってきて画面に表示をしたいのですが、画像表示されません。
|
6
|
-
|
7
|
-
|
8
4
|
|
9
5
|
### 発生している問題・エラーメッセージ
|
10
6
|
|
11
|
-
|
12
|
-
|
13
7
|
```
|
14
|
-
|
15
8
|
Value of type 'UIImage' has no member 'image'
|
16
|
-
|
17
9
|
```
|
18
10
|
|
19
11
|
|
@@ -22,250 +14,88 @@
|
|
22
14
|
|
23
15
|
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
17
|
```swift
|
34
|
-
|
35
18
|
import UIKit
|
36
19
|
|
37
|
-
|
38
|
-
|
39
|
-
class
|
20
|
+
class SViewController: UIViewController,UIScrollViewDelegate {
|
40
|
-
|
41
|
-
|
21
|
+
|
42
|
-
|
43
|
-
@IBOutlet weak var quizTextView: UITextView!
|
44
|
-
|
45
22
|
|
46
|
-
|
47
|
-
@IBOutlet weak var answerButton1: UIButton!
|
48
|
-
|
49
|
-
@IBOutlet weak var AnswerButton2: UIButton!
|
50
|
-
|
51
|
-
@IBOutlet weak var AnswerButton3: UIButton!
|
52
|
-
|
53
|
-
@IBOutlet weak var AnswerButton4: UIButton!
|
54
|
-
|
55
|
-
@IBOutlet weak var AnswerButton5: UIButton!
|
56
|
-
|
57
|
-
|
58
|
-
|
59
23
|
@IBOutlet weak var judgeImageView: UIImageView!
|
60
|
-
|
61
24
|
|
62
|
-
|
63
25
|
|
64
|
-
|
65
26
|
var csvArray: [String] = []
|
66
|
-
|
67
|
-
var quizArray: [String] = []
|
68
|
-
|
69
|
-
var quizCount = 0
|
70
|
-
|
71
27
|
|
72
|
-
|
73
28
|
|
74
|
-
|
75
29
|
@IBOutlet weak var scroll: UIScrollView!
|
76
|
-
|
77
30
|
@IBOutlet weak var image: UIImageView!
|
78
31
|
|
79
|
-
|
80
|
-
|
81
32
|
override func viewDidLoad() {
|
82
|
-
|
83
33
|
super.viewDidLoad()
|
84
|
-
|
85
34
|
|
86
|
-
|
87
35
|
csvArray = loadCSV(fileName: "quiz")
|
88
|
-
|
89
36
|
print(csvArray)
|
90
|
-
|
91
37
|
|
92
|
-
|
93
|
-
|
38
|
+
zArray = csvArray[quizCount].components(separatedBy: ",")
|
94
|
-
|
95
39
|
|
96
|
-
|
97
|
-
|
40
|
+
|
98
|
-
|
99
41
|
|
100
|
-
|
101
42
|
let Path = Bundle.main.path(forResource: quizArray[0]as AnyObject as? String, ofType: nil)
|
102
|
-
|
103
43
|
let image : UIImage = UIImage(contentsOfFile: Path!)!
|
104
|
-
|
105
44
|
|
106
|
-
|
107
45
|
// 画像が表示されません↓
|
108
|
-
|
109
|
-
image.image = (
|
46
|
+
image.image = (zArray[0])
|
110
|
-
|
111
|
-
|
47
|
+
|
112
|
-
|
113
|
-
AnswerButton2.setTitle(quizArray[3], for: .normal)
|
114
|
-
|
115
|
-
AnswerButton3.setTitle(quizArray[4], for: .normal)
|
116
|
-
|
117
|
-
AnswerButton4.setTitle(quizArray[5], for: .normal)
|
118
|
-
|
119
|
-
AnswerButton5.setTitle(quizArray[6], for: .normal)
|
120
|
-
|
121
48
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
49
|
scroll.delegate = self
|
126
|
-
|
127
50
|
scroll.maximumZoomScale = 5.0
|
128
|
-
|
129
51
|
scroll.minimumZoomScale = 1.0
|
130
52
|
|
131
|
-
|
132
|
-
|
133
53
|
}
|
134
|
-
|
135
54
|
func viewForZooming(in sclool:UIScrollView) -> UIView? {
|
136
55
|
|
137
|
-
|
138
|
-
|
139
56
|
return image}
|
140
|
-
|
141
57
|
|
142
|
-
|
143
58
|
//ボタンを押したときに呼ばれる
|
144
|
-
|
145
59
|
@IBAction func btnAction(sender: UIButton){
|
146
|
-
|
147
60
|
if sender.tag == Int(quizArray[1]){
|
148
|
-
|
149
|
-
print("
|
61
|
+
print("")
|
150
|
-
|
151
62
|
} else {
|
152
|
-
|
153
|
-
print("
|
63
|
+
print(")
|
154
|
-
|
155
64
|
}
|
156
|
-
|
157
|
-
nex
|
65
|
+
nex()
|
158
|
-
|
159
66
|
|
160
|
-
|
161
67
|
}
|
162
|
-
|
163
68
|
|
164
|
-
|
165
|
-
func next
|
69
|
+
func nextt() {
|
166
|
-
|
167
|
-
|
70
|
+
|
168
|
-
|
169
|
-
|
71
|
+
|
170
|
-
|
171
72
|
|
172
|
-
|
173
|
-
quizNumberLabel.text = "第(quizCount + 1)問"
|
174
|
-
|
175
|
-
|
176
|
-
|
177
73
|
//ここに次の画像に行ける、コードが欲しいのですがわかりません
|
178
74
|
|
179
|
-
|
180
|
-
|
181
|
-
|
75
|
+
|
182
|
-
|
183
|
-
AnswerButton2.setTitle(quizArray[3], for: .normal)
|
184
|
-
|
185
|
-
AnswerButton3.setTitle(quizArray[4], for: .normal)
|
186
|
-
|
187
|
-
AnswerButton4.setTitle(quizArray[5], for: .normal)
|
188
|
-
|
189
|
-
AnswerButton5.setTitle(quizArray[6], for: .normal)
|
190
|
-
|
191
76
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
77
|
}
|
196
|
-
|
197
78
|
|
198
|
-
|
199
79
|
func loadCSV(fileName: String) -> [String] {
|
200
|
-
|
201
80
|
let csvBundle = Bundle.main.path(forResource: fileName, ofType: "csv")!
|
202
|
-
|
203
81
|
do {
|
204
|
-
|
205
82
|
let csvDate = try String(contentsOfFile: csvBundle, encoding: String.Encoding.utf8)
|
206
|
-
|
207
83
|
let lineChange = csvDate.replacingOccurrences(of: "\r", with: "\n")
|
208
|
-
|
209
84
|
csvArray = lineChange.components(separatedBy: "\n")
|
210
|
-
|
211
85
|
csvArray.removeLast()
|
212
|
-
|
213
86
|
}catch{
|
214
|
-
|
215
87
|
print("エラ〜")
|
216
|
-
|
217
88
|
}
|
218
|
-
|
219
89
|
return csvArray
|
220
|
-
|
221
90
|
}
|
222
|
-
|
223
91
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
92
|
|
228
93
|
|
229
94
|
```
|
230
95
|
|
96
|
+
### 試したこと
|
231
97
|
|
232
|
-
|
233
|
-
|
98
|
+
色々と検索したり探したのですが、どうしても画像が入らず。。。。
|
234
99
|
|
235
100
|
|
236
101
|
|
237
|
-
色々と検索したり探したのですが、どうしても画像が入らず。。。。
|
238
|
-
|
239
|
-
また、次の問題に進むときに画像をまたcsvファイルの2段目にちゃんと移動したいです。
|
240
|
-
|
241
|
-
そもそもの画像は別ファイルにまとめて入れております。
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
csvファイルは
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
kougai1.png,1,1,2,3,4,5
|
252
|
-
|
253
|
-
kougai2.png,1,1,2,3,4,5
|
254
|
-
|
255
|
-
kougai3.png,1,1,2,3,4,5
|
256
|
-
|
257
|
-
kougai4.png,1,1,2,3,4,5
|
258
|
-
|
259
|
-
kougai5.png,1,1,2,3,4,5
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
最初にpng画像、正解番号 5択 です この画像がうまくImageViewに反映されません
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
### 補足情報(FW/ツールのバージョンなど)
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
ここにより詳細な情報を記載してください。
|