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

質問編集履歴

2

誤字

2018/06/15 06:19

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -257,7 +257,7 @@
257
257
  let resize = image.ResizeÜIImage(width: iw, height: iw*imgratio)
258
258
 
259
259
  self.BannerImage.append(img_path["img_path"].string!)
260
- print("BannerImage2は(self.BannerImage)")
260
+ print("BannerImageは(self.BannerImage)")
261
261
 
262
262
  self.banner.append(resize!)
263
263
  }

1

追記

2018/06/15 06:19

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -219,4 +219,48 @@
219
219
 
220
220
 
221
221
 
222
+ ```
223
+
224
+ また配列のことで気づいたことがあるので、追記致します。
225
+ load_date()のforeach部分ですが
226
+ indexを取得しようとしたところ、alamofireImageのメソッドに入るまでは
227
+ 綺麗な順番で数字が出力されるのに対し、メソッド内ではindexの順番がバラバラに
228
+ なります。また、新たに"BannerImage"というString型の配列を用意して、
229
+ "banner"と同じ工程をさせて、画像url表示の配列の中身を確認すると、バラバラなindex
230
+ 通りに画像が並んでおり、tableviewに表示されているものと同じものでした。
231
+ このことから、最終的には"banner"の配列の中身を,綺麗に並び変えることができれば良いのではないかと考えたのですが、そもそもなぜalamofireImageの中のindex番号はバラバラになるのでしょうか。。
232
+
233
+ ```
234
+ Alamofire.request("http://testapi~.php",method: .post, parameters: param).responseJSON { response in
235
+
236
+ guard let object = response.result.value else{
237
+ return
238
+ }
239
+ let jsons = JSON(object)
240
+
241
+ jsons["list"].forEach { (index, img_path) in
242
+
243
+ self.race_date_time.append(img_path["date"].string!)
244
+
245
+ print("ここでのindexの値は:(index)")//結果:0,1,2,3,.....綺麗な順番
246
+
247
+
248
+ Alamofire.request(img_path["url"].string!).responseImage { response in
249
+ debugPrint(response.result)
250
+ if let image = response.result.value {
251
+ print("image downloaded: (image)")
252
+
253
+ print("ここでのindexの値は:(index)")//結果:3,0,1,2,.....バラバラな順番
254
+
255
+ let imgratio:CGFloat = (image.size.height)/(image.size.width)
256
+ let iw = CGFloat(self.sw)
257
+ let resize = image.ResizeÜIImage(width: iw, height: iw*imgratio)
258
+
259
+ self.BannerImage.append(img_path["img_path"].string!)
260
+ print("BannerImage2は(self.BannerImage)")
261
+
262
+ self.banner.append(resize!)
263
+ }
264
+ }
265
+ }
222
266
  ```