質問編集履歴
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -516,7 +516,7 @@
|
|
516
516
|
|
517
517
|
self.BannerImage.append(img_path["img_path"].string!)
|
518
518
|
|
519
|
-
print("BannerImage
|
519
|
+
print("BannerImageは(self.BannerImage)")
|
520
520
|
|
521
521
|
|
522
522
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -441,3 +441,91 @@
|
|
441
441
|
|
442
442
|
|
443
443
|
```
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
また配列のことで気づいたことがあるので、追記致します。
|
448
|
+
|
449
|
+
load_date()のforeach部分ですが
|
450
|
+
|
451
|
+
indexを取得しようとしたところ、alamofireImageのメソッドに入るまでは
|
452
|
+
|
453
|
+
綺麗な順番で数字が出力されるのに対し、メソッド内ではindexの順番がバラバラに
|
454
|
+
|
455
|
+
なります。また、新たに"BannerImage"というString型の配列を用意して、
|
456
|
+
|
457
|
+
"banner"と同じ工程をさせて、画像url表示の配列の中身を確認すると、バラバラなindex
|
458
|
+
|
459
|
+
通りに画像が並んでおり、tableviewに表示されているものと同じものでした。
|
460
|
+
|
461
|
+
このことから、最終的には"banner"の配列の中身を,綺麗に並び変えることができれば良いのではないかと考えたのですが、そもそもなぜalamofireImageの中のindex番号はバラバラになるのでしょうか。。
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
```
|
466
|
+
|
467
|
+
Alamofire.request("http://testapi~.php",method: .post, parameters: param).responseJSON { response in
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
guard let object = response.result.value else{
|
472
|
+
|
473
|
+
return
|
474
|
+
|
475
|
+
}
|
476
|
+
|
477
|
+
let jsons = JSON(object)
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
jsons["list"].forEach { (index, img_path) in
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
self.race_date_time.append(img_path["date"].string!)
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
print("ここでのindexの値は:(index)")//結果:0,1,2,3,.....綺麗な順番
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
Alamofire.request(img_path["url"].string!).responseImage { response in
|
496
|
+
|
497
|
+
debugPrint(response.result)
|
498
|
+
|
499
|
+
if let image = response.result.value {
|
500
|
+
|
501
|
+
print("image downloaded: (image)")
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
print("ここでのindexの値は:(index)")//結果:3,0,1,2,.....バラバラな順番
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
let imgratio:CGFloat = (image.size.height)/(image.size.width)
|
510
|
+
|
511
|
+
let iw = CGFloat(self.sw)
|
512
|
+
|
513
|
+
let resize = image.ResizeÜIImage(width: iw, height: iw*imgratio)
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
self.BannerImage.append(img_path["img_path"].string!)
|
518
|
+
|
519
|
+
print("BannerImage2は(self.BannerImage)")
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
self.banner.append(resize!)
|
524
|
+
|
525
|
+
}
|
526
|
+
|
527
|
+
}
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
```
|